diff --git a/openlr/openlr_match_quality/CMakeLists.txt b/openlr/openlr_match_quality/CMakeLists.txt index b987e4646b..51db338865 100644 --- a/openlr/openlr_match_quality/CMakeLists.txt +++ b/openlr/openlr_match_quality/CMakeLists.txt @@ -1,3 +1,3 @@ project(openlr_match_quality) -add_subdirectory(assessment_tool) +add_subdirectory(openlr_assessment_tool) diff --git a/openlr/openlr_match_quality/assessment_tool/CMakeLists.txt b/openlr/openlr_match_quality/openlr_assessment_tool/CMakeLists.txt similarity index 100% rename from openlr/openlr_match_quality/assessment_tool/CMakeLists.txt rename to openlr/openlr_match_quality/openlr_assessment_tool/CMakeLists.txt diff --git a/openlr/openlr_match_quality/assessment_tool/Info.plist b/openlr/openlr_match_quality/openlr_assessment_tool/Info.plist similarity index 100% rename from openlr/openlr_match_quality/assessment_tool/Info.plist rename to openlr/openlr_match_quality/openlr_assessment_tool/Info.plist diff --git a/openlr/openlr_match_quality/assessment_tool/main.cpp b/openlr/openlr_match_quality/openlr_assessment_tool/main.cpp similarity index 91% rename from openlr/openlr_match_quality/assessment_tool/main.cpp rename to openlr/openlr_match_quality/openlr_assessment_tool/main.cpp index c6ea7c8637..cd5a9d7248 100644 --- a/openlr/openlr_match_quality/assessment_tool/main.cpp +++ b/openlr/openlr_match_quality/openlr_assessment_tool/main.cpp @@ -1,6 +1,6 @@ #include "map/framework.hpp" -#include "openlr/openlr_match_quality/assessment_tool/mainwindow.hpp" +#include "openlr/openlr_match_quality/openlr_assessment_tool/mainwindow.hpp" #include "3party/gflags/src/gflags/gflags.h" diff --git a/openlr/openlr_match_quality/assessment_tool/mainwindow.cpp b/openlr/openlr_match_quality/openlr_assessment_tool/mainwindow.cpp similarity index 85% rename from openlr/openlr_match_quality/assessment_tool/mainwindow.cpp rename to openlr/openlr_match_quality/openlr_assessment_tool/mainwindow.cpp index a0534443da..f2152d1727 100644 --- a/openlr/openlr_match_quality/assessment_tool/mainwindow.cpp +++ b/openlr/openlr_match_quality/openlr_assessment_tool/mainwindow.cpp @@ -1,7 +1,7 @@ -#include "openlr/openlr_match_quality/assessment_tool/mainwindow.hpp" +#include "openlr/openlr_match_quality/openlr_assessment_tool/mainwindow.hpp" -#include "openlr/openlr_match_quality/assessment_tool/traffic_panel.hpp" -#include "openlr/openlr_match_quality/assessment_tool/trafficmodeinitdlg.h" +#include "openlr/openlr_match_quality/openlr_assessment_tool/traffic_panel.hpp" +#include "openlr/openlr_match_quality/openlr_assessment_tool/trafficmodeinitdlg.h" #include "qt/qt_common/map_widget.hpp" @@ -86,18 +86,18 @@ MainWindow::MainWindow(Framework & framework) // setWindowTitle(tr("MAPS.ME")); // setWindowIcon(QIcon(":/ui/logo.png")); - QMenu * fileMenu = new QMenu(tr("File"), this); + QMenu * fileMenu = new QMenu("File", this); menuBar()->addMenu(fileMenu); - fileMenu->addAction(tr("Open sample"), this, &MainWindow::OnOpenTrafficSample); + fileMenu->addAction("Open sample", this, &MainWindow::OnOpenTrafficSample); m_closeTrafficSampleAction = fileMenu->addAction( - tr("Close sample"), this, &MainWindow::OnCloseTrafficSample + "Close sample", this, &MainWindow::OnCloseTrafficSample ); m_closeTrafficSampleAction->setEnabled(false /* enabled */); m_saveTrafficSampleAction = fileMenu->addAction( - tr("Save sample"), this, &MainWindow::OnSaveTrafficSample + "Save sample", this, &MainWindow::OnSaveTrafficSample ); m_saveTrafficSampleAction->setEnabled(false /* enabled */); } @@ -152,14 +152,14 @@ void MainWindow::OnCloseTrafficSample() void MainWindow::OnSaveTrafficSample() { // TODO(mgsergio): Add default filename. - auto const & fileName = QFileDialog::getSaveFileName(this, tr("Save sample")); + auto const & fileName = QFileDialog::getSaveFileName(this, "Save sample"); if (fileName.isEmpty()) return; if (!m_trafficMode->SaveSampleAs(fileName.toStdString())) { QMessageBox::critical( - this, tr("Saving error"), - tr("Can't save file: ") + strerror(errno)); + this, "Saving error", + QString("Can't save file: ") + strerror(errno)); } } diff --git a/openlr/openlr_match_quality/assessment_tool/mainwindow.hpp b/openlr/openlr_match_quality/openlr_assessment_tool/mainwindow.hpp similarity index 75% rename from openlr/openlr_match_quality/assessment_tool/mainwindow.hpp rename to openlr/openlr_match_quality/openlr_assessment_tool/mainwindow.hpp index 9543c7f5ab..f9e7dac26e 100644 --- a/openlr/openlr_match_quality/assessment_tool/mainwindow.hpp +++ b/openlr/openlr_match_quality/openlr_assessment_tool/mainwindow.hpp @@ -1,9 +1,11 @@ #pragma once -#include "openlr/openlr_match_quality/assessment_tool/traffic_mode.hpp" +#include "openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.hpp" #include "base/string_utils.hpp" +#include + #include class Framework; @@ -12,7 +14,7 @@ class TrafficMode; namespace df { class DrapeApi; -} // namespace df +} class QDockWidget; @@ -24,7 +26,7 @@ public: MainWindow(Framework & framework); private: - void CreateTrafficPanel(string const & dataFilePath, string const & sampleFilePath); + void CreateTrafficPanel(std::string const & dataFilePath, std::string const & sampleFilePath); void DestroyTrafficPanel(); void OnOpenTrafficSample(); diff --git a/openlr/openlr_match_quality/assessment_tool/traffic_mode.cpp b/openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.cpp similarity index 97% rename from openlr/openlr_match_quality/assessment_tool/traffic_mode.cpp rename to openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.cpp index 1839f9f9ec..cbd86d7069 100644 --- a/openlr/openlr_match_quality/assessment_tool/traffic_mode.cpp +++ b/openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.cpp @@ -1,4 +1,4 @@ -#include "openlr/openlr_match_quality/assessment_tool/traffic_mode.hpp" +#include "openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.hpp" #include "openlr/openlr_simple_parser.hpp" @@ -11,8 +11,6 @@ #include -#include - // DecodedSample ----------------------------------------------------------------------------------- DecodedSample::DecodedSample(Index const & index, openlr::SamplePool const & sample) @@ -171,6 +169,7 @@ void TrafficMode::OnItemSelected(QItemSelection const & selected, QItemSelection // TODO(mgsergio): Use algo for center calculation. // Now viewport is set to the first point of the first segment. + CHECK_LESS(row, m_decodedSample->m_decodedItems.size(), ()); auto & sampleItem = m_decodedSample->m_decodedItems[row]; auto const partnerSegmentId = sampleItem.m_partnerSegmentId; LOG(LINFO, ("Partner segment id:", partnerSegmentId)); diff --git a/openlr/openlr_match_quality/assessment_tool/traffic_mode.hpp b/openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.hpp similarity index 100% rename from openlr/openlr_match_quality/assessment_tool/traffic_mode.hpp rename to openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.hpp diff --git a/openlr/openlr_match_quality/assessment_tool/traffic_panel.cpp b/openlr/openlr_match_quality/openlr_assessment_tool/traffic_panel.cpp similarity index 94% rename from openlr/openlr_match_quality/assessment_tool/traffic_panel.cpp rename to openlr/openlr_match_quality/openlr_assessment_tool/traffic_panel.cpp index b27b3cefd1..27c4b4947f 100644 --- a/openlr/openlr_match_quality/assessment_tool/traffic_panel.cpp +++ b/openlr/openlr_match_quality/openlr_assessment_tool/traffic_panel.cpp @@ -1,5 +1,5 @@ -#include "openlr/openlr_match_quality/assessment_tool/traffic_panel.hpp" -#include "openlr/openlr_match_quality/assessment_tool/traffic_mode.hpp" +#include "openlr/openlr_match_quality/openlr_assessment_tool/traffic_panel.hpp" +#include "openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.hpp" #include #include diff --git a/openlr/openlr_match_quality/assessment_tool/traffic_panel.hpp b/openlr/openlr_match_quality/openlr_assessment_tool/traffic_panel.hpp similarity index 100% rename from openlr/openlr_match_quality/assessment_tool/traffic_panel.hpp rename to openlr/openlr_match_quality/openlr_assessment_tool/traffic_panel.hpp diff --git a/openlr/openlr_match_quality/assessment_tool/trafficmodeinitdlg.cpp b/openlr/openlr_match_quality/openlr_assessment_tool/trafficmodeinitdlg.cpp similarity index 95% rename from openlr/openlr_match_quality/assessment_tool/trafficmodeinitdlg.cpp rename to openlr/openlr_match_quality/openlr_assessment_tool/trafficmodeinitdlg.cpp index 348a9ca708..b144be3f0a 100644 --- a/openlr/openlr_match_quality/assessment_tool/trafficmodeinitdlg.cpp +++ b/openlr/openlr_match_quality/openlr_assessment_tool/trafficmodeinitdlg.cpp @@ -1,4 +1,4 @@ -#include "openlr/openlr_match_quality/assessment_tool/trafficmodeinitdlg.h" +#include "openlr/openlr_match_quality/openlr_assessment_tool/trafficmodeinitdlg.h" #include "ui_trafficmodeinitdlg.h" #include "platform/settings.hpp" diff --git a/openlr/openlr_match_quality/assessment_tool/trafficmodeinitdlg.h b/openlr/openlr_match_quality/openlr_assessment_tool/trafficmodeinitdlg.h similarity index 100% rename from openlr/openlr_match_quality/assessment_tool/trafficmodeinitdlg.h rename to openlr/openlr_match_quality/openlr_assessment_tool/trafficmodeinitdlg.h diff --git a/openlr/openlr_match_quality/assessment_tool/trafficmodeinitdlg.ui b/openlr/openlr_match_quality/openlr_assessment_tool/trafficmodeinitdlg.ui similarity index 100% rename from openlr/openlr_match_quality/assessment_tool/trafficmodeinitdlg.ui rename to openlr/openlr_match_quality/openlr_assessment_tool/trafficmodeinitdlg.ui diff --git a/openlr/openlr_sample.hpp b/openlr/openlr_sample.hpp index 98efb17d9c..a937dac1b3 100644 --- a/openlr/openlr_sample.hpp +++ b/openlr/openlr_sample.hpp @@ -15,6 +15,7 @@ namespace openlr { NEWTYPE(uint32_t, PartnerSegmentId); NEWTYPE_SIMPLE_OUTPUT(PartnerSegmentId); + enum class ItemEvaluation { Unevaluated, diff --git a/openlr/openlr_simple_decoder.cpp b/openlr/openlr_simple_decoder.cpp index 8a23202bfb..c20e1eeb26 100644 --- a/openlr/openlr_simple_decoder.cpp +++ b/openlr/openlr_simple_decoder.cpp @@ -52,6 +52,22 @@ struct alignas(kCacheLineSize) Stats uint32_t m_total = 0; }; +void SaveNonMatchedIds(string const & filename, std::vector const & segments, + std::vector const & paths) +{ + CHECK_EQUAL(segments.size(), paths.size(), ()); + + if (filename.empty()) + return; + + ofstream ofs(filename); + for (size_t i = 0; i < segments.size(); ++i) + { + if (paths[i].empty()) + ofs << segments[i].m_segmentId << endl; + } +} + openlr::SamplePool MakeSamplePool(std::vector const & segments, std::vector const & paths) { @@ -118,7 +134,8 @@ OpenLRSimpleDecoder::OpenLRSimpleDecoder(string const & dataFilename, vector const & indexes); - void Decode(std::string const & outputFilename, int segmentsToHandle, - SegmentsFilter const & filter, uint32_t numThreads); + void Decode(std::string const & outputFilename, std::string const & nonMatchedIdsFilename, + int segmentsToHandle, SegmentsFilter const & filter, uint32_t numThreads); private: std::vector const & m_indexes; diff --git a/openlr/openlr_stat/openlr_stat.cpp b/openlr/openlr_stat/openlr_stat.cpp index dc8bb5e108..f2d132e050 100644 --- a/openlr/openlr_stat/openlr_stat.cpp +++ b/openlr/openlr_stat/openlr_stat.cpp @@ -13,10 +13,13 @@ #include #include +#include #include DEFINE_string(input, "", "Path to OpenLR file."); DEFINE_string(output, "output.txt", "Path to output file"); +DEFINE_string(non_matched_ids, "non-matched-ids.txt", + "Path to a file ids of non-matched segments will be saved to"); DEFINE_string(mwms_path, "", "Path to a folder with mwms."); DEFINE_int32(limit, -1, "Max number of segments to handle. -1 for all."); DEFINE_bool(multipoints_only, false, "Only segments with multiple points to handle."); @@ -133,7 +136,7 @@ int main(int argc, char * argv[]) OpenLRSimpleDecoder::SegmentsFilter filter(FLAGS_ids_path, FLAGS_multipoints_only); OpenLRSimpleDecoder decoder(FLAGS_input, indexes); - decoder.Decode(FLAGS_output, FLAGS_limit, filter, numThreads); + decoder.Decode(FLAGS_output, FLAGS_non_matched_ids, FLAGS_limit, filter, numThreads); return 0; } diff --git a/openlr/router.cpp b/openlr/router.cpp index 48ac41e73c..d1a7ac9ec0 100644 --- a/openlr/router.cpp +++ b/openlr/router.cpp @@ -757,7 +757,6 @@ bool Router::ReconstructPath(std::vector & edges, vector & void Router::FindSingleEdgeApproximation(std::vector const & edges, std::vector & path) { - double const kThreshold = 0.8; double const kCoverageThreshold = 0.5; CHECK(all_of(edges.begin(), edges.end(), mem_fn(&Edge::IsFake)), ()); @@ -778,7 +777,7 @@ void Router::FindSingleEdgeApproximation(std::vector const & edges, GetCoverage(edge.GetStartJunction().GetPoint(), edge.GetEndJunction().GetPoint(), edges.begin(), edges.end()); double const coverage = weight * fraction; - if (fraction >= kThreshold && coverage >= bestCoverage) + if (coverage >= bestCoverage) { bestCoverage = coverage; bestEdge = edge; diff --git a/openlr/router.hpp b/openlr/router.hpp index e9cc11cf07..9c617a57da 100644 --- a/openlr/router.hpp +++ b/openlr/router.hpp @@ -39,6 +39,8 @@ private: bool operator==(Vertex const & rhs) const; bool operator!=(Vertex const & rhs) const { return !(*this == rhs); } + m2::PointD GetPoint() const { return m_junction.GetPoint(); } + routing::Junction m_junction; routing::Junction m_stageStart; double m_stageStartDistance = 0.0; diff --git a/platform/platform.cpp b/platform/platform.cpp index 1746f3fd91..aa679268fb 100644 --- a/platform/platform.cpp +++ b/platform/platform.cpp @@ -179,10 +179,10 @@ void Platform::GetFilesByType(string const & directory, unsigned typeMask, } // static -bool Platform::IsDirectory(string const & directory) +bool Platform::IsDirectory(string const & path) { EFileType fileType; - if (GetFileType(directory, fileType) != ERR_OK) + if (GetFileType(path, fileType) != ERR_OK) return false; return fileType == FILE_TYPE_DIRECTORY; } diff --git a/platform/platform.hpp b/platform/platform.hpp index 78fe9d76a1..28b8291808 100644 --- a/platform/platform.hpp +++ b/platform/platform.hpp @@ -165,7 +165,8 @@ public: TFilesWithType & outFiles); static bool IsDirectoryEmpty(string const & directory); - static bool IsDirectory(string const & directory); + // Returns true if |path| refers to a directory. Returns false otherwise or on error. + static bool IsDirectory(string const & path); static EError GetFileType(string const & path, EFileType & type); diff --git a/qt/mainwindow.hpp b/qt/mainwindow.hpp index 10fbfe076c..ddf2cdee6e 100644 --- a/qt/mainwindow.hpp +++ b/qt/mainwindow.hpp @@ -29,7 +29,7 @@ class MainWindow : public QMainWindow, location::LocationObserver { DrawWidget * m_pDrawWidget = nullptr; // TODO(mgsergio): Make indexing more informative. - array m_Docks; + std::array m_Docks; QPushButton * m_downloadButton = nullptr; QPushButton * m_retryButton = nullptr;