diff --git a/android/jni/com/mapswithme/maps/Framework.cpp b/android/jni/com/mapswithme/maps/Framework.cpp index b6d30d100c..9979a1181e 100644 --- a/android/jni/com/mapswithme/maps/Framework.cpp +++ b/android/jni/com/mapswithme/maps/Framework.cpp @@ -284,7 +284,7 @@ Storage & Framework::GetStorage() return m_work.GetStorage(); } -DataSourceBase const & Framework::GetIndex() { return m_work.GetIndex(); } +DataSourceBase const & Framework::GetDataSource() { return m_work.GetDataSource(); } void Framework::ShowNode(TCountryId const & idx, bool zoomToDownloadButton) { diff --git a/android/jni/com/mapswithme/maps/Framework.hpp b/android/jni/com/mapswithme/maps/Framework.hpp index 902a055a34..bb75b5c2ad 100644 --- a/android/jni/com/mapswithme/maps/Framework.hpp +++ b/android/jni/com/mapswithme/maps/Framework.hpp @@ -81,7 +81,7 @@ namespace android Framework(); storage::Storage & GetStorage(); - DataSourceBase const & GetIndex(); + DataSourceBase const & GetDataSource(); void ShowNode(storage::TCountryId const & countryId, bool zoomToDownloadButton); diff --git a/android/jni/com/mapswithme/maps/ugc/UGC.cpp b/android/jni/com/mapswithme/maps/ugc/UGC.cpp index 0f58fb176e..e05b1ba77a 100644 --- a/android/jni/com/mapswithme/maps/ugc/UGC.cpp +++ b/android/jni/com/mapswithme/maps/ugc/UGC.cpp @@ -33,8 +33,8 @@ public: auto const version = static_cast(jversion); auto const index = static_cast(jindex); - auto const & ix = g_framework->GetIndex(); - auto const id = ix.GetMwmIdByCountryFile(platform::CountryFile(countryName)); + auto const & ds = g_framework->GetDataSource(); + auto const id = ds.GetMwmIdByCountryFile(platform::CountryFile(countryName)); return FeatureID(id, index); } diff --git a/editor/editor_tests/osm_editor_test.cpp b/editor/editor_tests/osm_editor_test.cpp index acef4955e5..c5224b6c6c 100644 --- a/editor/editor_tests/osm_editor_test.cpp +++ b/editor/editor_tests/osm_editor_test.cpp @@ -53,7 +53,7 @@ public: }; template -void ForEachCafeAtPoint(DataSourceBase & index, m2::PointD const & mercator, TFn && fn) +void ForEachCafeAtPoint(DataSourceBase & dataSource, m2::PointD const & mercator, TFn && fn) { m2::RectD const rect = MercatorBounds::RectByCenterXYAndSizeInMeters(mercator, 0.2 /* rect width */); @@ -65,7 +65,7 @@ void ForEachCafeAtPoint(DataSourceBase & index, m2::PointD const & mercator, TFn } }; - index.ForEachInRect(f, rect, scales::GetUpperScale()); + dataSource.ForEachInRect(f, rect, scales::GetUpperScale()); } void FillEditableMapObject(osm::Editor const & editor, FeatureType const & ft, osm::EditableMapObject & emo) @@ -147,7 +147,7 @@ EditorTest::EditorTest() LOG(LERROR, ("Classificator read error: ", e.what())); } - editor::tests_support::SetUpEditorForTesting(make_unique(m_index)); + editor::tests_support::SetUpEditorForTesting(make_unique(m_dataSource)); } EditorTest::~EditorTest() @@ -174,7 +174,7 @@ void EditorTest::GetFeatureTypeInfoTest() builder.Add(cafe); }); - ForEachCafeAtPoint(m_index, m2::PointD(1.0, 1.0), [&editor](FeatureType & ft) + ForEachCafeAtPoint(m_dataSource, m2::PointD(1.0, 1.0), [&editor](FeatureType & ft) { TEST(!editor.GetFeatureTypeInfo(ft.GetID().m_mwmId, ft.GetID().m_index), ()); @@ -202,7 +202,7 @@ void EditorTest::GetEditedFeatureTest() builder.Add(cafe); }); - ForEachCafeAtPoint(m_index, m2::PointD(1.0, 1.0), [&editor](FeatureType & ft) + ForEachCafeAtPoint(m_dataSource, m2::PointD(1.0, 1.0), [&editor](FeatureType & ft) { FeatureType featureType; TEST(!editor.GetEditedFeature(ft.GetID(), featureType), ()); @@ -245,7 +245,7 @@ void EditorTest::SetIndexTest() osm::EditableMapObject emo; CreateCafeAtPoint({2.0, 2.0}, gbMwmId, emo); - ForEachCafeAtPoint(m_index, m2::PointD(1.0, 1.0), [&editor](FeatureType & ft) + ForEachCafeAtPoint(m_dataSource, m2::PointD(1.0, 1.0), [&editor](FeatureType & ft) { auto const firstPtr = editor.GetOriginalFeature(ft.GetID()); TEST(firstPtr, ()); @@ -255,7 +255,7 @@ void EditorTest::SetIndexTest() TEST_EQUAL(firstPtr->GetID(), secondPtr->GetID(), ()); }); - ForEachCafeAtPoint(m_index, m2::PointD(1.0, 1.0), [&editor](FeatureType & ft) + ForEachCafeAtPoint(m_dataSource, m2::PointD(1.0, 1.0), [&editor](FeatureType & ft) { TEST_EQUAL(editor.GetOriginalFeatureStreet(ft), "Test street", ()); @@ -316,7 +316,7 @@ void EditorTest::GetEditedFeatureStreetTest() builder.Add(cafe); }); - ForEachCafeAtPoint(m_index, m2::PointD(1.0, 1.0), [&editor](FeatureType & ft) + ForEachCafeAtPoint(m_dataSource, m2::PointD(1.0, 1.0), [&editor](FeatureType & ft) { string street; TEST(!editor.GetEditedFeatureStreet(ft.GetID(), street), ()); @@ -345,7 +345,7 @@ void EditorTest::GetFeatureStatusTest() builder.Add(unnamedCafe); }); - ForEachCafeAtPoint(m_index, m2::PointD(1.0, 1.0), [&editor](FeatureType & ft) + ForEachCafeAtPoint(m_dataSource, m2::PointD(1.0, 1.0), [&editor](FeatureType & ft) { TEST_EQUAL(editor.GetFeatureStatus(ft.GetID()), FeatureStatus::Untouched, ()); @@ -359,7 +359,7 @@ void EditorTest::GetFeatureStatusTest() TEST_EQUAL(editor.GetFeatureStatus(emo.GetID()), FeatureStatus::Obsolete, ()); }); - ForEachCafeAtPoint(m_index, m2::PointD(2.0, 2.0), [&editor](FeatureType & ft) + ForEachCafeAtPoint(m_dataSource, m2::PointD(2.0, 2.0), [&editor](FeatureType & ft) { TEST_EQUAL(editor.GetFeatureStatus(ft.GetID()), FeatureStatus::Untouched, ()); editor.DeleteFeature(ft.GetID()); @@ -384,7 +384,7 @@ void EditorTest::IsFeatureUploadedTest() builder.Add(TestPOI(m2::PointD(10, 10), "Corner Post", "default")); }); - ForEachCafeAtPoint(m_index, m2::PointD(1.0, 1.0), [&editor](FeatureType & ft) + ForEachCafeAtPoint(m_dataSource, m2::PointD(1.0, 1.0), [&editor](FeatureType & ft) { TEST(!editor.IsFeatureUploaded(ft.GetID().m_mwmId, ft.GetID().m_index), ()); }); @@ -423,7 +423,7 @@ void EditorTest::DeleteFeatureTest() TEST_EQUAL(editor.GetFeatureStatus(ft.GetID()), FeatureStatus::Untouched, ()); - ForEachCafeAtPoint(m_index, m2::PointD(1.0, 1.0), [&editor](FeatureType & ft) + ForEachCafeAtPoint(m_dataSource, m2::PointD(1.0, 1.0), [&editor](FeatureType & ft) { editor.DeleteFeature(ft.GetID()); TEST_EQUAL(editor.GetFeatureStatus(ft.GetID()), FeatureStatus::Deleted, ()); @@ -475,7 +475,7 @@ void EditorTest::GetFeaturesByStatusTest() FeatureID modifiedId, deletedId, obsoleteId, createdId; - ForEachCafeAtPoint(m_index, m2::PointD(1.0, 1.0), [&editor, &modifiedId](FeatureType & ft) + ForEachCafeAtPoint(m_dataSource, m2::PointD(1.0, 1.0), [&editor, &modifiedId](FeatureType & ft) { osm::EditableMapObject emo; FillEditableMapObject(editor, ft, emo); @@ -485,13 +485,13 @@ void EditorTest::GetFeaturesByStatusTest() modifiedId = emo.GetID(); }); - ForEachCafeAtPoint(m_index, m2::PointD(2.0, 2.0), [&editor, &deletedId](FeatureType & ft) + ForEachCafeAtPoint(m_dataSource, m2::PointD(2.0, 2.0), [&editor, &deletedId](FeatureType & ft) { editor.DeleteFeature(ft.GetID()); deletedId = ft.GetID(); }); - ForEachCafeAtPoint(m_index, m2::PointD(3.0, 3.0), [&editor, &obsoleteId](FeatureType & ft) + ForEachCafeAtPoint(m_dataSource, m2::PointD(3.0, 3.0), [&editor, &obsoleteId](FeatureType & ft) { editor.MarkFeatureAsObsolete(ft.GetID()); obsoleteId = ft.GetID(); @@ -533,12 +533,12 @@ void EditorTest::OnMapDeregisteredTest() builder.Add(cafeMoscow); }); - ForEachCafeAtPoint(m_index, m2::PointD(1.0, 1.0), [](FeatureType & ft) + ForEachCafeAtPoint(m_dataSource, m2::PointD(1.0, 1.0), [](FeatureType & ft) { SetBuildingLevelsToOne(ft); }); - ForEachCafeAtPoint(m_index, m2::PointD(2.0, 2.0), [](FeatureType & ft) + ForEachCafeAtPoint(m_dataSource, m2::PointD(2.0, 2.0), [](FeatureType & ft) { SetBuildingLevelsToOne(ft); }); @@ -566,7 +566,7 @@ void EditorTest::RollBackChangesTest() const string houseNumber = "4a"; - ForEachCafeAtPoint(m_index, m2::PointD(1.0, 1.0), [&editor, &houseNumber](FeatureType & ft) + ForEachCafeAtPoint(m_dataSource, m2::PointD(1.0, 1.0), [&editor, &houseNumber](FeatureType & ft) { osm::EditableMapObject emo; FillEditableMapObject(editor, ft, emo); @@ -574,17 +574,17 @@ void EditorTest::RollBackChangesTest() TEST_EQUAL(editor.SaveEditedFeature(emo), osm::Editor::SaveResult::SavedSuccessfully, ()); }); - ForEachCafeAtPoint(m_index, m2::PointD(1.0, 1.0), [&houseNumber](FeatureType & ft) + ForEachCafeAtPoint(m_dataSource, m2::PointD(1.0, 1.0), [&houseNumber](FeatureType & ft) { TEST_EQUAL(ft.GetHouseNumber(), houseNumber, ()); }); - ForEachCafeAtPoint(m_index, m2::PointD(1.0, 1.0), [&editor](FeatureType & ft) + ForEachCafeAtPoint(m_dataSource, m2::PointD(1.0, 1.0), [&editor](FeatureType & ft) { editor.RollBackChanges(ft.GetID()); }); - ForEachCafeAtPoint(m_index, m2::PointD(1.0, 1.0), [](FeatureType & ft) + ForEachCafeAtPoint(m_dataSource, m2::PointD(1.0, 1.0), [](FeatureType & ft) { TEST_EQUAL(ft.GetHouseNumber(), "", ()); }); @@ -602,7 +602,7 @@ void EditorTest::HaveMapEditsOrNotesToUploadTest() TEST(!editor.HaveMapEditsOrNotesToUpload(), ()); - ForEachCafeAtPoint(m_index, m2::PointD(1.0, 1.0), [](FeatureType & ft) + ForEachCafeAtPoint(m_dataSource, m2::PointD(1.0, 1.0), [](FeatureType & ft) { SetBuildingLevelsToOne(ft); }); @@ -615,7 +615,7 @@ void EditorTest::HaveMapEditsOrNotesToUploadTest() editor.m_notes = Notes::MakeNotes(sf.GetFullPath(), true); - ForEachCafeAtPoint(m_index, m2::PointD(1.0, 1.0), [&editor](FeatureType & ft) + ForEachCafeAtPoint(m_dataSource, m2::PointD(1.0, 1.0), [&editor](FeatureType & ft) { using NoteType = osm::Editor::NoteProblemType; feature::TypesHolder typesHolder; @@ -646,7 +646,7 @@ void EditorTest::HaveMapEditsToUploadTest() TEST(!editor.HaveMapEditsToUpload(gbMwmId), ()); TEST(!editor.HaveMapEditsToUpload(rfMwmId), ()); - ForEachCafeAtPoint(m_index, m2::PointD(1.0, 1.0), [](FeatureType & ft) + ForEachCafeAtPoint(m_dataSource, m2::PointD(1.0, 1.0), [](FeatureType & ft) { SetBuildingLevelsToOne(ft); }); @@ -654,7 +654,7 @@ void EditorTest::HaveMapEditsToUploadTest() TEST(editor.HaveMapEditsToUpload(gbMwmId), ()); TEST(!editor.HaveMapEditsToUpload(rfMwmId), ()); - ForEachCafeAtPoint(m_index, m2::PointD(2.0, 2.0), [](FeatureType & ft) + ForEachCafeAtPoint(m_dataSource, m2::PointD(2.0, 2.0), [](FeatureType & ft) { SetBuildingLevelsToOne(ft); }); @@ -684,7 +684,7 @@ void EditorTest::GetStatsTest() TEST_EQUAL(stats.m_uploadedCount, 0, ()); TEST_EQUAL(stats.m_lastUploadTimestamp, my::INVALID_TIME_STAMP, ()); - ForEachCafeAtPoint(m_index, m2::PointD(1.0, 1.0), [](FeatureType & ft) + ForEachCafeAtPoint(m_dataSource, m2::PointD(1.0, 1.0), [](FeatureType & ft) { SetBuildingLevelsToOne(ft); }); @@ -692,7 +692,7 @@ void EditorTest::GetStatsTest() stats = editor.GetStats(); TEST_EQUAL(stats.m_edits.size(), 1, ()); - ForEachCafeAtPoint(m_index, m2::PointD(4.0, 4.0), [](FeatureType & ft) + ForEachCafeAtPoint(m_dataSource, m2::PointD(4.0, 4.0), [](FeatureType & ft) { SetBuildingLevelsToOne(ft); }); @@ -700,7 +700,7 @@ void EditorTest::GetStatsTest() stats = editor.GetStats(); TEST_EQUAL(stats.m_edits.size(), 2, ()); - ForEachCafeAtPoint(m_index, m2::PointD(5.0, 5.0), [](FeatureType & ft) + ForEachCafeAtPoint(m_dataSource, m2::PointD(5.0, 5.0), [](FeatureType & ft) { SetBuildingLevelsToOne(ft); }); @@ -734,7 +734,7 @@ void EditorTest::IsCreatedFeatureTest() builder.Add(TestPOI(m2::PointD(10, 10), "Corner Post", "default")); }); - ForEachCafeAtPoint(m_index, m2::PointD(1.0, 1.0), [&editor](FeatureType & ft) + ForEachCafeAtPoint(m_dataSource, m2::PointD(1.0, 1.0), [&editor](FeatureType & ft) { TEST(!editor.IsCreatedFeature(ft.GetID()), ()); SetBuildingLevelsToOne(ft); @@ -806,7 +806,7 @@ void EditorTest::CreateNoteTest() TEST_NOT_EQUAL(notes.front().m_note.find("Test name"), string::npos, ()); }; - ForEachCafeAtPoint(m_index, m2::PointD(1.0, 1.0), [&editor, &createAndCheckNote](FeatureType & ft) + ForEachCafeAtPoint(m_dataSource, m2::PointD(1.0, 1.0), [&editor, &createAndCheckNote](FeatureType & ft) { createAndCheckNote(ft.GetID(), {1.0, 1.0}, osm::Editor::NoteProblemType::PlaceDoesNotExist); @@ -815,7 +815,7 @@ void EditorTest::CreateNoteTest() TEST_EQUAL(editor.GetFeatureStatus(ft.GetID()), FeatureStatus::Obsolete, ()); }); - ForEachCafeAtPoint(m_index, m2::PointD(2.0, 2.0), [&editor, &createAndCheckNote](FeatureType & ft) + ForEachCafeAtPoint(m_dataSource, m2::PointD(2.0, 2.0), [&editor, &createAndCheckNote](FeatureType & ft) { createAndCheckNote(ft.GetID(), {2.0, 2.0}, osm::Editor::NoteProblemType::General); @@ -849,37 +849,37 @@ void EditorTest::LoadMapEditsTest() vector features; - ForEachCafeAtPoint(m_index, m2::PointD(0.0, 0.0), [&features](FeatureType & ft) + ForEachCafeAtPoint(m_dataSource, m2::PointD(0.0, 0.0), [&features](FeatureType & ft) { SetBuildingLevelsToOne(ft); features.emplace_back(ft.GetID()); }); - ForEachCafeAtPoint(m_index, m2::PointD(1.0, 1.0), [&editor, &features](FeatureType & ft) + ForEachCafeAtPoint(m_dataSource, m2::PointD(1.0, 1.0), [&editor, &features](FeatureType & ft) { editor.DeleteFeature(ft.GetID()); features.emplace_back(ft.GetID()); }); - ForEachCafeAtPoint(m_index, m2::PointD(2.0, 2.0), [&editor, &features](FeatureType & ft) + ForEachCafeAtPoint(m_dataSource, m2::PointD(2.0, 2.0), [&editor, &features](FeatureType & ft) { editor.MarkFeatureAsObsolete(ft.GetID()); features.emplace_back(ft.GetID()); }); - ForEachCafeAtPoint(m_index, m2::PointD(7.0, 7.0), [&features](FeatureType & ft) + ForEachCafeAtPoint(m_dataSource, m2::PointD(7.0, 7.0), [&features](FeatureType & ft) { SetBuildingLevelsToOne(ft); features.emplace_back(ft.GetID()); }); - ForEachCafeAtPoint(m_index, m2::PointD(4.0, 4.0), [&editor, &features](FeatureType & ft) + ForEachCafeAtPoint(m_dataSource, m2::PointD(4.0, 4.0), [&editor, &features](FeatureType & ft) { editor.DeleteFeature(ft.GetID()); features.emplace_back(ft.GetID()); }); - ForEachCafeAtPoint(m_index, m2::PointD(6.0, 6.0), [&features](FeatureType & ft) + ForEachCafeAtPoint(m_dataSource, m2::PointD(6.0, 6.0), [&features](FeatureType & ft) { SetBuildingLevelsToOne(ft); features.emplace_back(ft.GetID()); @@ -926,7 +926,7 @@ void EditorTest::LoadMapEditsTest() TEST_EQUAL(features.size(), loadedFeatures.size(), ()); - m_index.DeregisterMap(m_mwmFiles.back().GetCountryFile()); + m_dataSource.DeregisterMap(m_mwmFiles.back().GetCountryFile()); TEST(RemoveMwm(newRfMwmId), ()); TEST_EQUAL(editor.m_features.size(), 2, ()); @@ -949,7 +949,7 @@ void EditorTest::LoadMapEditsTest() TEST_EQUAL(editor.m_features.size(), 1, ()); TEST_EQUAL(loadedFeatures.size(), 1, ()); - m_index.DeregisterMap(m_mwmFiles.back().GetCountryFile()); + m_dataSource.DeregisterMap(m_mwmFiles.back().GetCountryFile()); TEST(RemoveMwm(gbMwmId), ()); auto const newGbMwmId = BuildMwm("GB", [](TestMwmBuilder & builder) @@ -985,7 +985,7 @@ void EditorTest::SaveEditedFeatureTest() TEST_EQUAL(editor.SaveEditedFeature(emo), osm::Editor::SaveResult::NothingWasChanged, ()); TEST_EQUAL(editor.GetFeatureStatus(emo.GetID()), FeatureStatus::Created, ()); - ForEachCafeAtPoint(m_index, m2::PointD(1.0, 1.0), [&editor](FeatureType & ft) + ForEachCafeAtPoint(m_dataSource, m2::PointD(1.0, 1.0), [&editor](FeatureType & ft) { osm::EditableMapObject emo; FillEditableMapObject(editor, ft, emo); diff --git a/editor/editor_tests/osm_editor_test.hpp b/editor/editor_tests/osm_editor_test.hpp index 79d428c42f..a0c7829bd5 100644 --- a/editor/editor_tests/osm_editor_test.hpp +++ b/editor/editor_tests/osm_editor_test.hpp @@ -62,7 +62,7 @@ private: fn(builder); } - auto result = m_index.RegisterMap(file); + auto result = m_dataSource.RegisterMap(file); CHECK_EQUAL(result.second, MwmSet::RegResult::Success, ()); auto const & id = result.first; @@ -79,7 +79,7 @@ private: void Cleanup(platform::LocalCountryFile const & map); bool RemoveMwm(MwmSet::MwmId const & mwmId); - EditableDataSource m_index; + EditableDataSource m_dataSource; storage::CountryInfoGetterForTesting m_infoGetter; vector m_mwmFiles; }; diff --git a/feature_list/feature_list.cpp b/feature_list/feature_list.cpp index 4c3a94647c..0ef127a163 100644 --- a/feature_list/feature_list.cpp +++ b/feature_list/feature_list.cpp @@ -178,11 +178,11 @@ class Processor search::LocalityFinder m_finder; public: - Processor(DataSourceBase const & index) - : m_geocoder(index) - , m_boundariesTable(index) + Processor(DataSourceBase const & dataSource) + : m_geocoder(dataSource) + , m_boundariesTable(dataSource) , m_villagesCache(m_cancellable) - , m_finder(index, m_boundariesTable, m_villagesCache) + , m_finder(dataSource, m_boundariesTable, m_villagesCache) { m_boundariesTable.Load(); } @@ -324,23 +324,23 @@ int main(int argc, char ** argv) classificator::Load(); classif().SortClassificator(); - DataSource index; + DataSource dataSource; vector mwms; platform::FindAllLocalMapsAndCleanup(numeric_limits::max() /* the latest version */, mwms); for (auto & mwm : mwms) { mwm.SyncWithDisk(); - auto const & p = index.RegisterMap(mwm); + auto const & p = dataSource.RegisterMap(mwm); CHECK_EQUAL(MwmSet::RegResult::Success, p.second, ("Could not register map", mwm)); MwmSet::MwmId const & id = p.first; CHECK(id.IsAlive(), ("Mwm is not alive?", mwm)); } - Processor doProcess(index); + Processor doProcess(dataSource); PrintHeader(); vector> mwmInfos; - index.GetMwmsInfo(mwmInfos); + dataSource.GetMwmsInfo(mwmInfos); for (auto const & mwmInfo : mwmInfos) { if (mwmInfo->GetType() != MwmInfo::COUNTRY) @@ -353,7 +353,7 @@ int main(int argc, char ** argv) map featureIdToOsmId; ParseFeatureIdToOsmIdMapping(osmToFeatureFile, featureIdToOsmId); MwmSet::MwmId mwmId(mwmInfo); - DataSource::FeaturesLoaderGuard loader(index, mwmId); + DataSource::FeaturesLoaderGuard loader(dataSource, mwmId); for (uint32_t ftIndex = 0; ftIndex < loader.GetNumFeatures(); ftIndex++) { FeatureType ft; diff --git a/generator/cities_boundaries_builder.cpp b/generator/cities_boundaries_builder.cpp index f70a0c71c6..1f8a09ece6 100644 --- a/generator/cities_boundaries_builder.cpp +++ b/generator/cities_boundaries_builder.cpp @@ -67,11 +67,11 @@ bool ParseFeatureIdToTestIdMapping(string const & path, map const & roads, LocalCountryFi builder.Add(generator::tests_support::TestStreet(ExtractPoints(geom3D), std::string(), std::string())); } -void TestAltitudes(DataSourceBase const & index, MwmSet::MwmId const & mwmId, std::string const & mwmPath, +void TestAltitudes(DataSourceBase const & dataSource, MwmSet::MwmId const & mwmId, std::string const & mwmPath, bool hasAltitudeExpected, AltitudeGetter & expectedAltitudes) { - AltitudeLoader loader(index, mwmId); + AltitudeLoader loader(dataSource, mwmId); TEST_EQUAL(loader.HasAltitudes(), hasAltitudeExpected, ()); auto processor = [&expectedAltitudes, &loader](FeatureType const & f, uint32_t const & id) @@ -181,11 +181,11 @@ void TestAltitudesBuilding(vector const & roads, bool hasAltitudeE BuildRoadAltitudes(mwmPath, altitudeGetter); // Reading from mwm and testing altitude information. - DataSource index; - auto const regResult = index.RegisterMap(country); + DataSource dataSource; + auto const regResult = dataSource.RegisterMap(country); TEST_EQUAL(regResult.second, MwmSet::RegResult::Success, ()); - TestAltitudes(index, regResult.first /* mwmId */, mwmPath, hasAltitudeExpected, altitudeGetter); + TestAltitudes(dataSource, regResult.first /* mwmId */, mwmPath, hasAltitudeExpected, altitudeGetter); } void TestBuildingAllFeaturesHaveAltitude(vector const & roads, bool hasAltitudeExpected) diff --git a/generator/generator_tests_support/test_with_custom_mwms.hpp b/generator/generator_tests_support/test_with_custom_mwms.hpp index e3bfdc0191..06409815c3 100644 --- a/generator/generator_tests_support/test_with_custom_mwms.hpp +++ b/generator/generator_tests_support/test_with_custom_mwms.hpp @@ -47,7 +47,7 @@ public: fn(builder); } - auto result = m_index.RegisterMap(file); + auto result = m_dataSource.RegisterMap(file); CHECK_EQUAL(result.second, MwmSet::RegResult::Success, ()); auto const id = result.first; @@ -66,7 +66,7 @@ public: if (it == m_files.end()) return; - m_index.DeregisterMap(file); + m_dataSource.DeregisterMap(file); Cleanup(*it); m_files.erase(it); } @@ -88,7 +88,7 @@ protected: virtual void OnMwmBuilt(MwmInfo const & /* info */) {} - EditableDataSource m_index; + EditableDataSource m_dataSource; std::vector m_files; }; } // namespace tests_support diff --git a/generator/search_index_builder.cpp b/generator/search_index_builder.cpp index 4f3ead1caa..f1fe253d77 100644 --- a/generator/search_index_builder.cpp +++ b/generator/search_index_builder.cpp @@ -323,11 +323,11 @@ void BuildAddressTable(FilesContainerR & container, Writer & writer) uint32_t address = 0, missing = 0; map bounds; - DataSource mwmIndex; + DataSource dataSource; /// @ todo Make some better solution, or legalize MakeTemporary. - auto const res = mwmIndex.RegisterMap(platform::LocalCountryFile::MakeTemporary(container.GetFileName())); + auto const res = dataSource.RegisterMap(platform::LocalCountryFile::MakeTemporary(container.GetFileName())); ASSERT_EQUAL(res.second, MwmSet::RegResult::Success, ()); - search::ReverseGeocoder rgc(mwmIndex); + search::ReverseGeocoder rgc(dataSource); { FixedBitsDDVector<3, FileReader>::Builder building2Street(writer); diff --git a/generator/sponsored_dataset_inl.hpp b/generator/sponsored_dataset_inl.hpp index cc0f077a08..09dcd46dcc 100644 --- a/generator/sponsored_dataset_inl.hpp +++ b/generator/sponsored_dataset_inl.hpp @@ -20,8 +20,8 @@ class AddressMatcher public: AddressMatcher() { - LoadIndex(m_index); - m_coder = make_unique(m_index); + LoadDataSource(m_dataSource); + m_coder = make_unique(m_dataSource); } template @@ -34,7 +34,7 @@ public: } private: - DataSource m_index; + DataSource m_dataSource; std::unique_ptr m_coder; }; diff --git a/generator/transit_generator.cpp b/generator/transit_generator.cpp index 86da85f2c6..fe7208b096 100644 --- a/generator/transit_generator.cpp +++ b/generator/transit_generator.cpp @@ -72,7 +72,7 @@ void CalculateBestPedestrianSegments(string const & mwmPath, TCountryId const & GraphData & graphData) { // Creating IndexRouter. - SingleMwmDataSource index(mwmPath); + SingleMwmDataSource dataSource(mwmPath); auto infoGetter = storage::CountryInfoReader::CreateCountryInfoReader(GetPlatform()); CHECK(infoGetter, ()); @@ -86,15 +86,15 @@ void CalculateBestPedestrianSegments(string const & mwmPath, TCountryId const & return infoGetter->GetLimitRectForLeaf(c); }; - CHECK_EQUAL(index.GetMwmId().GetInfo()->GetType(), MwmInfo::COUNTRY, ()); + CHECK_EQUAL(dataSource.GetMwmId().GetInfo()->GetType(), MwmInfo::COUNTRY, ()); auto numMwmIds = make_shared(); numMwmIds->RegisterFile(CountryFile(countryId)); - // Note. |indexRouter| is valid while |index| is valid. + // Note. |indexRouter| is valid while |dataSource| is valid. IndexRouter indexRouter(VehicleType::Pedestrian, false /* load altitudes */, CountryParentNameGetterFn(), countryFileGetter, getMwmRectByName, numMwmIds, MakeNumMwmTree(*numMwmIds, *infoGetter), - traffic::TrafficCache(), index.GetIndex()); + traffic::TrafficCache(), dataSource.GetDataSource()); auto worldGraph = indexRouter.MakeSingleMwmWorldGraph(); // Looking for the best segment for every gate. diff --git a/generator/utils.cpp b/generator/utils.cpp index bbb0b51e85..235fe2c175 100644 --- a/generator/utils.cpp +++ b/generator/utils.cpp @@ -9,7 +9,7 @@ namespace generator { -// SingleMwmIndex --------------------------------------------------------------------------------- +// SingleMwmDataSource ----------------------------------------------------------------------------- SingleMwmDataSource::SingleMwmDataSource(std::string const & mwmPath) { m_countryFile = platform::LocalCountryFile::MakeTemporary(mwmPath); @@ -18,13 +18,13 @@ SingleMwmDataSource::SingleMwmDataSource(std::string const & mwmPath) m_countryFile.GetFiles(), MapOptions::MapWithCarRouting, ("No correct mwm corresponding to local country file:", m_countryFile, ". Path:", mwmPath)); - auto const result = m_index.Register(m_countryFile); + auto const result = m_dataSource.Register(m_countryFile); CHECK_EQUAL(result.second, MwmSet::RegResult::Success, ()); CHECK(result.first.IsAlive(), ()); m_mwmId = result.first; } -void LoadIndex(DataSourceBase & index) +void LoadDataSource(DataSourceBase & dataSource) { vector localFiles; @@ -36,7 +36,7 @@ void LoadIndex(DataSourceBase & index) LOG(LINFO, ("Found mwm:", localFile)); try { - index.RegisterMap(localFile); + dataSource.RegisterMap(localFile); } catch (RootException const & ex) { diff --git a/generator/utils.hpp b/generator/utils.hpp index cbd469d2eb..037eee5d84 100644 --- a/generator/utils.hpp +++ b/generator/utils.hpp @@ -22,20 +22,20 @@ namespace generator class SingleMwmDataSource { public: - /// \param mwmPath is a path to mwm which should be registerd in Index. + /// \param mwmPath is a path to mwm which should be registerd in DataSource. explicit SingleMwmDataSource(std::string const & mwmPath); - DataSourceBase & GetIndex() { return m_index; } + DataSourceBase & GetDataSource() { return m_dataSource; } std::string GetPath(MapOptions file) const { return m_countryFile.GetPath(file); } MwmSet::MwmId const & GetMwmId() const { return m_mwmId; } private: - DataSource m_index; + DataSource m_dataSource; platform::LocalCountryFile m_countryFile; MwmSet::MwmId m_mwmId; }; -void LoadIndex(DataSourceBase & index); +void LoadDataSource(DataSourceBase & dataSource); template bool ForEachOsmId2FeatureId(std::string const & path, ToDo && toDo) diff --git a/generator/viator_dataset.cpp b/generator/viator_dataset.cpp index 12155d87d4..07fdda0edf 100644 --- a/generator/viator_dataset.cpp +++ b/generator/viator_dataset.cpp @@ -56,8 +56,8 @@ ostream & operator<<(ostream & s, ViatorCity const & h) ViatorDataset::ViatorDataset(std::string const & dataPath) : m_storage(3000.0 /* distanceLimitMeters */, 3 /* maxSelectedElements */) { - LoadIndex(m_index); - m_cityFinder = make_unique(m_index); + LoadDataSource(m_dataSource); + m_cityFinder = make_unique(m_dataSource); m_storage.LoadData(dataPath); } diff --git a/generator/viator_dataset.hpp b/generator/viator_dataset.hpp index 98cb821283..0b0ecdca8c 100644 --- a/generator/viator_dataset.hpp +++ b/generator/viator_dataset.hpp @@ -50,7 +50,7 @@ public: private: SponsoredObjectStorage m_storage; - DataSource m_index; + DataSource m_dataSource; std::unique_ptr m_cityFinder; }; } // namespace generator diff --git a/indexer/altitude_loader.cpp b/indexer/altitude_loader.cpp index 65c3748219..8e54d52034 100644 --- a/indexer/altitude_loader.cpp +++ b/indexer/altitude_loader.cpp @@ -31,8 +31,8 @@ void LoadAndMap(size_t dataSize, ReaderSource & src, T namespace feature { -AltitudeLoader::AltitudeLoader(DataSourceBase const & index, MwmSet::MwmId const & mwmId) - : m_handle(index.GetMwmHandleById(mwmId)) +AltitudeLoader::AltitudeLoader(DataSourceBase const & dataSource, MwmSet::MwmId const & mwmId) + : m_handle(dataSource.GetMwmHandleById(mwmId)) { if (!m_handle.IsAlive()) return; diff --git a/indexer/altitude_loader.hpp b/indexer/altitude_loader.hpp index 81a7cca025..ceb089e7e2 100644 --- a/indexer/altitude_loader.hpp +++ b/indexer/altitude_loader.hpp @@ -17,7 +17,7 @@ namespace feature class AltitudeLoader { public: - AltitudeLoader(DataSourceBase const & index, MwmSet::MwmId const & mwmId); + AltitudeLoader(DataSourceBase const & dataSource, MwmSet::MwmId const & mwmId); /// \returns altitude of feature with |featureId|. All items of the returned vector are valid /// or the returned vector is empty. diff --git a/indexer/data_source.hpp b/indexer/data_source.hpp index 5a0c8f3b7e..8e8edfb2d0 100644 --- a/indexer/data_source.hpp +++ b/indexer/data_source.hpp @@ -237,8 +237,8 @@ public: class FeaturesLoaderGuard { public: - FeaturesLoaderGuard(DataSourceBase const & index, MwmId const & id) - : m_handle(index.GetMwmHandleById(id)), m_source(m_handle) + FeaturesLoaderGuard(DataSourceBase const & dataSource, MwmId const & id) + : m_handle(dataSource.GetMwmHandleById(id)), m_source(m_handle) { } diff --git a/indexer/data_source_helpers.cpp b/indexer/data_source_helpers.cpp index 9f46af8f39..210a0af1e9 100644 --- a/indexer/data_source_helpers.cpp +++ b/indexer/data_source_helpers.cpp @@ -6,45 +6,44 @@ namespace indexer { -void ForEachFeatureAtPoint(DataSourceBase const & index, function && fn, m2::PointD const & mercator, double toleranceInMeters) +void ForEachFeatureAtPoint(DataSourceBase const & dataSource, function && fn, + m2::PointD const & mercator, double toleranceInMeters) { double constexpr kSelectRectWidthInMeters = 1.1; double constexpr kMetersToLinearFeature = 3; int constexpr kScale = scales::GetUpperScale(); - m2::RectD const rect = MercatorBounds::RectByCenterXYAndSizeInMeters(mercator, kSelectRectWidthInMeters); + m2::RectD const rect = + MercatorBounds::RectByCenterXYAndSizeInMeters(mercator, kSelectRectWidthInMeters); - auto const emitter = [&fn, &rect, &mercator, toleranceInMeters](FeatureType & ft) - { - switch (ft.GetFeatureType()) - { - case feature::GEOM_POINT: - if (rect.IsPointInside(ft.GetCenter())) - fn(ft); - break; - case feature::GEOM_LINE: - if (feature::GetMinDistanceMeters(ft, mercator) < kMetersToLinearFeature) - fn(ft); - break; - case feature::GEOM_AREA: - { - auto limitRect = ft.GetLimitRect(kScale); - // Be a little more tolerant. When used by editor mercator is given - // with some error, so we must extend limit rect a bit. - limitRect.Inflate(MercatorBounds::GetCellID2PointAbsEpsilon(), - MercatorBounds::GetCellID2PointAbsEpsilon()); - if (limitRect.IsPointInside(mercator) && - feature::GetMinDistanceMeters(ft, mercator) <= toleranceInMeters) - { - fn(ft); - } - } - break; - case feature::GEOM_UNDEFINED: - ASSERT(false, ("case feature::GEOM_UNDEFINED")); - break; - } + auto const emitter = [&fn, &rect, &mercator, toleranceInMeters](FeatureType & ft) { + switch (ft.GetFeatureType()) + { + case feature::GEOM_POINT: + if (rect.IsPointInside(ft.GetCenter())) + fn(ft); + break; + case feature::GEOM_LINE: + if (feature::GetMinDistanceMeters(ft, mercator) < kMetersToLinearFeature) + fn(ft); + break; + case feature::GEOM_AREA: + { + auto limitRect = ft.GetLimitRect(kScale); + // Be a little more tolerant. When used by editor mercator is given + // with some error, so we must extend limit rect a bit. + limitRect.Inflate(MercatorBounds::GetCellID2PointAbsEpsilon(), + MercatorBounds::GetCellID2PointAbsEpsilon()); + if (limitRect.IsPointInside(mercator) && + feature::GetMinDistanceMeters(ft, mercator) <= toleranceInMeters) + { + fn(ft); + } + } + break; + case feature::GEOM_UNDEFINED: ASSERT(false, ("case feature::GEOM_UNDEFINED")); break; + } }; - index.ForEachInRect(emitter, rect, kScale); + dataSource.ForEachInRect(emitter, rect, kScale); } } // namespace indexer diff --git a/indexer/data_source_helpers.hpp b/indexer/data_source_helpers.hpp index f3fa1a5157..f7dc7a4582 100644 --- a/indexer/data_source_helpers.hpp +++ b/indexer/data_source_helpers.hpp @@ -9,6 +9,6 @@ class FeatureType; namespace indexer { -void ForEachFeatureAtPoint(DataSourceBase const & index, function && fn, +void ForEachFeatureAtPoint(DataSourceBase const & dataSource, function && fn, m2::PointD const & mercator, double toleranceInMeters = 0.0); } diff --git a/indexer/indexer_tests/CMakeLists.txt b/indexer/indexer_tests/CMakeLists.txt index 5542d88f33..650b64dc7a 100644 --- a/indexer/indexer_tests/CMakeLists.txt +++ b/indexer/indexer_tests/CMakeLists.txt @@ -10,6 +10,7 @@ set( centers_table_test.cpp checker_test.cpp cities_boundaries_serdes_tests.cpp + data_source_test.cpp drules_selector_parser_test.cpp editable_map_object_test.cpp feature_metadata_test.cpp @@ -17,7 +18,6 @@ set( features_offsets_table_test.cpp features_vector_test.cpp index_builder_test.cpp - index_test.cpp interval_index_test.cpp locality_index_test.cpp mwm_set_test.cpp diff --git a/indexer/indexer_tests/index_test.cpp b/indexer/indexer_tests/data_source_test.cpp similarity index 83% rename from indexer/indexer_tests/index_test.cpp rename to indexer/indexer_tests/data_source_test.cpp index 0b59c41b74..c5b64905da 100644 --- a/indexer/indexer_tests/index_test.cpp +++ b/indexer/indexer_tests/data_source_test.cpp @@ -25,12 +25,12 @@ using platform::LocalCountryFile; namespace { -class IndexTest : public MwmSet::Observer +class DataSourceTest : public MwmSet::Observer { public: - IndexTest() { TEST(m_index.AddObserver(*this), ()); } + DataSourceTest() { TEST(m_dataSource.AddObserver(*this), ()); } - ~IndexTest() override { TEST(m_index.RemoveObserver(*this), ()); } + ~DataSourceTest() override { TEST(m_dataSource.RemoveObserver(*this), ()); } void ExpectRegistered(platform::LocalCountryFile const & localFile) { @@ -86,21 +86,21 @@ protected: events.emplace_back(forward(args)...); } - DataSource m_index; + DataSource m_dataSource; vector m_expected; vector m_actual; }; } // namespace -UNIT_CLASS_TEST(IndexTest, Parse) +UNIT_CLASS_TEST(DataSourceTest, Parse) { - UNUSED_VALUE(m_index.RegisterMap(platform::LocalCountryFile::MakeForTesting("minsk-pass"))); + UNUSED_VALUE(m_dataSource.RegisterMap(platform::LocalCountryFile::MakeForTesting("minsk-pass"))); // Make sure that index is actually parsed. - m_index.ForEachInScale([](FeatureType &) { return; }, 15); + m_dataSource.ForEachInScale([](FeatureType &) { return; }, 15); } -UNIT_CLASS_TEST(IndexTest, StatusNotifications) +UNIT_CLASS_TEST(DataSourceTest, StatusNotifications) { string const mapsDir = GetPlatform().WritableDir(); CountryFile const country("minsk-pass"); @@ -115,7 +115,7 @@ UNIT_CLASS_TEST(IndexTest, StatusNotifications) // Checks that observers are triggered after map registration. { - auto result = m_index.RegisterMap(file1); + auto result = m_dataSource.RegisterMap(file1); TEST_EQUAL(MwmSet::RegResult::Success, result.second, ()); id1 = result.first; @@ -127,7 +127,7 @@ UNIT_CLASS_TEST(IndexTest, StatusNotifications) // Checks that map can't registered twice. { - auto result = m_index.RegisterMap(file1); + auto result = m_dataSource.RegisterMap(file1); TEST_EQUAL(MwmSet::RegResult::VersionAlreadyExists, result.second, ()); TEST(result.first.IsAlive(), ()); @@ -139,7 +139,7 @@ UNIT_CLASS_TEST(IndexTest, StatusNotifications) // Checks that observers are notified when map is updated. MwmSet::MwmId id2; { - auto result = m_index.RegisterMap(file2); + auto result = m_dataSource.RegisterMap(file2); TEST_EQUAL(MwmSet::RegResult::Success, result.second, ()); id2 = result.first; @@ -155,10 +155,10 @@ UNIT_CLASS_TEST(IndexTest, StatusNotifications) // leaving the inner block the map should be deregistered. { { - MwmSet::MwmHandle const handle = m_index.GetMwmHandleByCountryFile(country); + MwmSet::MwmHandle const handle = m_dataSource.GetMwmHandleByCountryFile(country); TEST(handle.IsAlive(), ()); - TEST(!m_index.DeregisterMap(country), ()); + TEST(!m_dataSource.DeregisterMap(country), ()); TEST(CheckExpectations(), ()); } diff --git a/indexer/indexer_tests/features_vector_test.cpp b/indexer/indexer_tests/features_vector_test.cpp index 8d8b7f6114..ed0fdb80e6 100644 --- a/indexer/indexer_tests/features_vector_test.cpp +++ b/indexer/indexer_tests/features_vector_test.cpp @@ -50,12 +50,12 @@ UNIT_TEST(FeaturesVectorTest_ParseMetadata) LocalCountryFile localFile = LocalCountryFile::MakeForTesting(kCountryName); - DataSource index; - auto result = index.RegisterMap(localFile); + DataSource dataSource; + auto result = dataSource.RegisterMap(localFile); TEST_EQUAL(result.second, MwmSet::RegResult::Success, ()); auto const & id = result.first; - MwmSet::MwmHandle handle = index.GetMwmHandleById(id); + MwmSet::MwmHandle handle = dataSource.GetMwmHandleById(id); TEST(handle.IsAlive(), ()); auto const * value = handle.GetValue(); diff --git a/indexer/indexer_tests/index_builder_test.cpp b/indexer/indexer_tests/index_builder_test.cpp index f13662a455..aa60d56f1a 100644 --- a/indexer/indexer_tests/index_builder_test.cpp +++ b/indexer/indexer_tests/index_builder_test.cpp @@ -52,11 +52,11 @@ UNIT_TEST(BuildIndexTest) { // Check that index actually works. - DataSource index; - UNUSED_VALUE(index.Register(platform::LocalCountryFile::MakeForTesting("build_index_test"))); + DataSource dataSource; + UNUSED_VALUE(dataSource.Register(platform::LocalCountryFile::MakeForTesting("build_index_test"))); // Make sure that index is actually parsed. - index.ForEachInScale([](FeatureType &) { return; }, 15); + dataSource.ForEachInScale([](FeatureType &) { return; }, 15); } // Clean after the test. diff --git a/indexer/indexer_tests/rank_table_test.cpp b/indexer/indexer_tests/rank_table_test.cpp index 359c3db3b4..54f9a78b62 100644 --- a/indexer/indexer_tests/rank_table_test.cpp +++ b/indexer/indexer_tests/rank_table_test.cpp @@ -97,8 +97,8 @@ UNIT_TEST(RankTableBuilder_EndToEnd) search::RankTableBuilder::Create(ranks, wcont); } - DataSource index; - auto regResult = index.RegisterMap(localFile); + DataSource dataSource; + auto regResult = dataSource.RegisterMap(localFile); TEST_EQUAL(regResult.second, MwmSet::RegResult::Success, ()); TestTable(ranks, mapPath); diff --git a/indexer/indexer_tests/scale_index_reading_tests.cpp b/indexer/indexer_tests/scale_index_reading_tests.cpp index 9bbf2bb6da..4718f14445 100644 --- a/indexer/indexer_tests/scale_index_reading_tests.cpp +++ b/indexer/indexer_tests/scale_index_reading_tests.cpp @@ -54,7 +54,7 @@ public: [&](uint32_t index) { indices.push_back(index); }); } - DataSource::FeaturesLoaderGuard loader(m_index, id); + DataSource::FeaturesLoaderGuard loader(m_dataSource, id); Names names; for (auto const & index : indices) diff --git a/map/address_finder.cpp b/map/address_finder.cpp index 49e7f76e1e..b2eaa3f3f2 100644 --- a/map/address_finder.cpp +++ b/map/address_finder.cpp @@ -460,7 +460,7 @@ search::AddressInfo Framework::GetAddressInfoAtPoint(m2::PointD const & pt) cons search::AddressInfo info; - search::ReverseGeocoder const coder(m_model.GetIndex()); + search::ReverseGeocoder const coder(m_model.GetDataSource()); search::ReverseGeocoder::Address addr; coder.GetNearbyAddress(pt, addr); @@ -492,7 +492,7 @@ search::AddressInfo Framework::GetFeatureAddressInfo(FeatureType & ft) const // @TODO(vng): Temporarily commented - it's slow and not used in UI. //GetLocality(pt, info); - search::ReverseGeocoder const coder(m_model.GetIndex()); + search::ReverseGeocoder const coder(m_model.GetDataSource()); search::ReverseGeocoder::Address addr; if (coder.GetExactAddress(ft, addr)) { diff --git a/map/booking_availability_filter.cpp b/map/booking_availability_filter.cpp index 352125a7bb..723c6630da 100644 --- a/map/booking_availability_filter.cpp +++ b/map/booking_availability_filter.cpp @@ -88,7 +88,7 @@ void FillResults(HotelToResults && hotelToResults, std::vector cons } } -void PrepareData(DataSourceBase const & index, search::Results const & results, +void PrepareData(DataSourceBase const & dataSource, search::Results const & results, HotelToResults & hotelToResults, availability::Cache & cache, booking::AvailabilityParams & p) { @@ -111,7 +111,7 @@ void PrepareData(DataSourceBase const & index, search::Results const & results, { if (mwmId != featureId.m_mwmId) { - guard = my::make_unique(index, featureId.m_mwmId); + guard = my::make_unique(dataSource, featureId.m_mwmId); mwmId = featureId.m_mwmId; } @@ -164,7 +164,7 @@ void AvailabilityFilter::ApplyFilter(search::Results const & results, m_apiParams.m_hotelIds.clear(); HotelToResults hotelToResults; - PrepareData(GetDelegate().GetIndex(), results, hotelToResults, *m_cache, m_apiParams); + PrepareData(GetDelegate().GetDataSource(), results, hotelToResults, *m_cache, m_apiParams); if (m_apiParams.m_hotelIds.empty()) { @@ -229,7 +229,7 @@ void AvailabilityFilter::GetFeaturesFromCache(search::Results const & results, if (mwmId != featureId.m_mwmId) { guard = - my::make_unique(GetDelegate().GetIndex(), featureId.m_mwmId); + my::make_unique(GetDelegate().GetDataSource(), featureId.m_mwmId); mwmId = featureId.m_mwmId; } diff --git a/map/booking_filter.hpp b/map/booking_filter.hpp index 0e45884238..bf4fbf71ba 100644 --- a/map/booking_filter.hpp +++ b/map/booking_filter.hpp @@ -28,7 +28,7 @@ public: public: virtual ~Delegate() = default; - virtual DataSourceBase const & GetIndex() const = 0; + virtual DataSourceBase const & GetDataSource() const = 0; virtual Api const & GetApi() const = 0; }; diff --git a/map/booking_filter_processor.cpp b/map/booking_filter_processor.cpp index 09ca114e4b..22d1cf0f28 100644 --- a/map/booking_filter_processor.cpp +++ b/map/booking_filter_processor.cpp @@ -7,8 +7,8 @@ namespace booking { namespace filter { -FilterProcessor::FilterProcessor(DataSourceBase const & index, booking::Api const & api) - : m_index(index) +FilterProcessor::FilterProcessor(DataSourceBase const & dataSource, booking::Api const & api) + : m_dataSource(dataSource) , m_api(api) { m_filters.emplace(Type::Deals, std::make_unique(*this)); @@ -60,9 +60,9 @@ void FilterProcessor::GetFeaturesFromCache(Types const & types, search::Results }); } -DataSourceBase const & FilterProcessor::GetIndex() const +DataSourceBase const & FilterProcessor::GetDataSource() const { - return m_index; + return m_dataSource; } Api const & FilterProcessor::GetApi() const diff --git a/map/booking_filter_processor.hpp b/map/booking_filter_processor.hpp index 0017bdc0d0..0b0a91aa35 100644 --- a/map/booking_filter_processor.hpp +++ b/map/booking_filter_processor.hpp @@ -46,7 +46,7 @@ using FillSearchMarksCallback = class FilterProcessor : public FilterBase::Delegate { public: - FilterProcessor(DataSourceBase const & index, booking::Api const & api); + FilterProcessor(DataSourceBase const & dataSource, booking::Api const & api); void ApplyFilters(search::Results const & results, TasksInternal && tasks, ApplicationMode const mode); @@ -57,14 +57,14 @@ public: FillSearchMarksCallback const & callback); // FilterInterface::Delegate overrides: - DataSourceBase const & GetIndex() const override; + DataSourceBase const & GetDataSource() const override; Api const & GetApi() const override; private: void ApplyConsecutively(search::Results const & results, TasksInternal & tasks); void ApplyIndependently(search::Results const & results, TasksInternal const & tasks); - DataSourceBase const & m_index; + DataSourceBase const & m_dataSource; Api const & m_api; std::unordered_map m_filters; diff --git a/map/discovery/discovery_manager.cpp b/map/discovery/discovery_manager.cpp index 40965df746..35fb7a5f66 100644 --- a/map/discovery/discovery_manager.cpp +++ b/map/discovery/discovery_manager.cpp @@ -21,8 +21,8 @@ std::string GetQuery(discovery::ItemType const type) namespace discovery { -Manager::Manager(DataSourceBase const & index, search::CityFinder & cityFinder, APIs const & apis) - : m_index(index) +Manager::Manager(DataSourceBase const & dataSource, search::CityFinder & cityFinder, APIs const & apis) + : m_dataSource(dataSource) , m_cityFinder(cityFinder) , m_searchApi(apis.m_search) , m_viatorApi(apis.m_viator) @@ -67,7 +67,7 @@ std::string Manager::GetCityViatorId(m2::PointD const & point) const if (!fid.IsValid()) return {}; - EditableDataSource::FeaturesLoaderGuard const guard(m_index, fid.m_mwmId); + EditableDataSource::FeaturesLoaderGuard const guard(m_dataSource, fid.m_mwmId); FeatureType ft; if (!guard.GetFeatureByIndex(fid.m_index, ft)) { diff --git a/map/discovery/discovery_manager.hpp b/map/discovery/discovery_manager.hpp index 2565247267..c6010fda04 100644 --- a/map/discovery/discovery_manager.hpp +++ b/map/discovery/discovery_manager.hpp @@ -54,7 +54,7 @@ public: using ErrorCalback = std::function; - Manager(DataSourceBase const & index, search::CityFinder & cityFinder, APIs const & apis); + Manager(DataSourceBase const & dataSource, search::CityFinder & cityFinder, APIs const & apis); template uint32_t Discover(Params && params, ResultCallback const & onResult, ErrorCalback const & onError) @@ -153,7 +153,7 @@ private: static search::DiscoverySearchParams GetSearchParams(Manager::Params const & params, ItemType const type); std::string GetCityViatorId(m2::PointD const & point) const; - DataSourceBase const & m_index; + DataSourceBase const & m_dataSource; search::CityFinder & m_cityFinder; SearchAPI & m_searchApi; viator::Api const & m_viatorApi; diff --git a/map/feature_vec_model.cpp b/map/feature_vec_model.cpp index b6bbaa955b..d265a178a3 100644 --- a/map/feature_vec_model.cpp +++ b/map/feature_vec_model.cpp @@ -18,12 +18,12 @@ namespace model { FeaturesFetcher::FeaturesFetcher() { - m_multiIndex.AddObserver(*this); + m_dataSource.AddObserver(*this); } FeaturesFetcher::~FeaturesFetcher() { - m_multiIndex.RemoveObserver(*this); + m_dataSource.RemoveObserver(*this); } // While reading any files (classificator or mwm), there are 2 types of possible exceptions: @@ -47,7 +47,7 @@ pair FeaturesFetcher::RegisterMap( { try { - auto result = m_multiIndex.RegisterMap(localFile); + auto result = m_dataSource.RegisterMap(localFile); if (result.second != MwmSet::RegResult::Success) { LOG(LWARNING, ("Can't add map", localFile.GetCountryName(), "(", result.second, ").", @@ -71,14 +71,14 @@ pair FeaturesFetcher::RegisterMap( bool FeaturesFetcher::DeregisterMap(CountryFile const & countryFile) { - return m_multiIndex.Deregister(countryFile); + return m_dataSource.Deregister(countryFile); } -void FeaturesFetcher::Clear() { m_multiIndex.Clear(); } +void FeaturesFetcher::Clear() { m_dataSource.Clear(); } void FeaturesFetcher::ClearCaches() { - m_multiIndex.ClearCache(); + m_dataSource.ClearCache(); } void FeaturesFetcher::OnMapUpdated(platform::LocalCountryFile const & newFile, diff --git a/map/feature_vec_model.hpp b/map/feature_vec_model.hpp index a3b0b355d5..c3e397563d 100644 --- a/map/feature_vec_model.hpp +++ b/map/feature_vec_model.hpp @@ -31,7 +31,7 @@ class FeaturesFetcher : public MwmSet::Observer private: m2::RectD m_rect; - EditableDataSource m_multiIndex; + EditableDataSource m_dataSource; TMapDeregisteredCallback m_onMapDeregistered; @@ -60,7 +60,7 @@ class FeaturesFetcher : public MwmSet::Observer inline bool IsLoaded(string const & countryFileName) const { - return m_multiIndex.IsLoaded(platform::CountryFile(countryFileName)); + return m_dataSource.IsLoaded(platform::CountryFile(countryFileName)); } // MwmSet::Observer overrides: @@ -75,24 +75,24 @@ class FeaturesFetcher : public MwmSet::Observer void ForEachFeature(m2::RectD const & rect, std::function const & fn, int scale) const { - m_multiIndex.ForEachInRect(fn, rect, scale); + m_dataSource.ForEachInRect(fn, rect, scale); } void ForEachFeatureID(m2::RectD const & rect, std::function const & fn, int scale) const { - m_multiIndex.ForEachFeatureIDInRect(fn, rect, scale); + m_dataSource.ForEachFeatureIDInRect(fn, rect, scale); } template void ReadFeatures(ToDo & toDo, vector const & features) const { - m_multiIndex.ReadFeatures(toDo, features); + m_dataSource.ReadFeatures(toDo, features); } //@} - DataSourceBase const & GetIndex() const { return m_multiIndex; } - DataSourceBase & GetIndex() { return m_multiIndex; } + DataSourceBase const & GetDataSource() const { return m_dataSource; } + DataSourceBase & GetDataSource() { return m_dataSource; } m2::RectD GetWorldRect() const; }; } diff --git a/map/framework.cpp b/map/framework.cpp index 9f812536d1..a3b0124706 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -359,21 +359,21 @@ Framework::Framework(FrameworkParams const & params) , m_storage(platform::migrate::NeedMigrate() ? COUNTRIES_OBSOLETE_FILE : COUNTRIES_FILE) , m_enabledDiffs(params.m_enableDiffs) , m_isRenderingEnabled(true) - , m_transitManager(m_model.GetIndex(), + , m_transitManager(m_model.GetDataSource(), [this](FeatureCallback const & fn, vector const & features) { return m_model.ReadFeatures(fn, features); }, bind(&Framework::GetMwmsByRect, this, _1, false /* rough */)) , m_routingManager( RoutingManager::Callbacks( - [this]() -> DataSourceBase & { return m_model.GetIndex(); }, + [this]() -> DataSourceBase & { return m_model.GetDataSource(); }, [this]() -> storage::CountryInfoGetter & { return GetCountryInfoGetter(); }, [this](string const & id) -> string { return m_storage.GetParentIdFor(id); }, [this]() -> StringsBundle const & { return m_stringsBundle; }), static_cast(*this)) , m_trafficManager(bind(&Framework::GetMwmsByRect, this, _1, false /* rough */), kMaxTrafficCacheSizeBytes, m_routingManager.RoutingSession()) - , m_bookingFilterProcessor(m_model.GetIndex(), *m_bookingApi) + , m_bookingFilterProcessor(m_model.GetDataSource(), *m_bookingApi) , m_displacementModeManager([this](bool show) { int const mode = show ? dp::displacement::kHotelMode : dp::displacement::kDefaultMode; if (m_drapeEngine != nullptr) @@ -473,11 +473,11 @@ Framework::Framework(FrameworkParams const & params) osm::Editor & editor = osm::Editor::Instance(); - editor.SetDelegate(make_unique(m_model.GetIndex())); + editor.SetDelegate(make_unique(m_model.GetDataSource())); editor.SetInvalidateFn([this](){ InvalidateRect(GetCurrentViewport()); }); editor.LoadEdits(); - m_model.GetIndex().AddObserver(editor); + m_model.GetDataSource().AddObserver(editor); LOG(LINFO, ("Editor initialized")); @@ -622,7 +622,7 @@ void Framework::OnMapDeregistered(platform::LocalCountryFile const & localFile) else GetPlatform().RunTask(Platform::Thread::Gui, action); - auto const mwmId = m_model.GetIndex().GetMwmIdByCountryFile(localFile.GetCountryFile()); + auto const mwmId = m_model.GetDataSource().GetMwmIdByCountryFile(localFile.GetCountryFile()); m_trafficManager.OnMwmDeregistered(mwmId); m_transitManager.OnMwmDeregistered(mwmId); } @@ -636,7 +636,7 @@ bool Framework::HasUnsavedEdits(storage::TCountryId const & countryId) if (groupNode) return; hasUnsavedChanges |= osm::Editor::Instance().HaveMapEditsToUpload( - m_model.GetIndex().GetMwmIdByCountryFile(platform::CountryFile(fileName))); + m_model.GetDataSource().GetMwmIdByCountryFile(platform::CountryFile(fileName))); }; GetStorage().ForEachInSubtree(countryId, forEachInSubtree); return hasUnsavedChanges; @@ -744,7 +744,7 @@ void Framework::FillFeatureInfo(FeatureID const & fid, place_page::Info & info) return; } - EditableDataSource::FeaturesLoaderGuard const guard(m_model.GetIndex(), fid.m_mwmId); + EditableDataSource::FeaturesLoaderGuard const guard(m_model.GetDataSource(), fid.m_mwmId); FeatureType ft; if (!guard.GetFeatureByIndex(fid.m_index, ft)) { @@ -1324,7 +1324,7 @@ void Framework::InitUGC() { ASSERT(!m_ugcApi.get(), ("InitUGC() must be called only once.")); - m_ugcApi = make_unique(m_model.GetIndex(), [this](size_t numberOfUnsynchronized) { + m_ugcApi = make_unique(m_model.GetDataSource(), [this](size_t numberOfUnsynchronized) { if (numberOfUnsynchronized == 0) return; @@ -1341,7 +1341,7 @@ void Framework::InitSearchAPI() try { m_searchAPI = - make_unique(m_model.GetIndex(), m_storage, *m_infoGetter, + make_unique(m_model.GetDataSource(), m_storage, *m_infoGetter, static_cast(*this)); } catch (RootException const & e) @@ -1357,7 +1357,7 @@ void Framework::InitDiscoveryManager() discovery::Manager::APIs const apis(*m_searchAPI.get(), *m_viatorApi.get(), *m_localsApi.get()); m_discoveryManager = - make_unique(m_model.GetIndex(), *m_cityFinder.get(), apis); + make_unique(m_model.GetDataSource(), *m_cityFinder.get(), apis); } void Framework::InitTransliteration() @@ -2043,7 +2043,7 @@ unique_ptr Framework::GetFeatureAtPoint(m2::PointD const & mercator { unique_ptr poi, line, area; uint32_t const coastlineType = classif().GetCoastType(); - indexer::ForEachFeatureAtPoint(m_model.GetIndex(), [&, coastlineType](FeatureType & ft) + indexer::ForEachFeatureAtPoint(m_model.GetDataSource(), [&, coastlineType](FeatureType & ft) { // TODO @alexz // remove manual parsing after refactoring with usermarks'll be finished @@ -2077,7 +2077,7 @@ bool Framework::GetFeatureByID(FeatureID const & fid, FeatureType & ft) const { ASSERT(fid.IsValid(), ()); - EditableDataSource::FeaturesLoaderGuard guard(m_model.GetIndex(), fid.m_mwmId); + EditableDataSource::FeaturesLoaderGuard guard(m_model.GetDataSource(), fid.m_mwmId); if (!guard.GetFeatureByIndex(fid.m_index, ft)) return false; @@ -2598,7 +2598,7 @@ vector Framework::GetSelectedFeatureTriangles() const if (!m_selectedFeature.IsValid()) return triangles; - EditableDataSource::FeaturesLoaderGuard const guard(m_model.GetIndex(), m_selectedFeature.m_mwmId); + EditableDataSource::FeaturesLoaderGuard const guard(m_model.GetDataSource(), m_selectedFeature.m_mwmId); FeatureType ft; if (!guard.GetFeatureByIndex(m_selectedFeature.m_index, ft)) return triangles; @@ -2732,10 +2732,10 @@ bool Framework::ParseEditorDebugCommand(search::SearchParams const & params) namespace { -WARN_UNUSED_RESULT bool LocalizeStreet(DataSourceBase const & index, FeatureID const & fid, +WARN_UNUSED_RESULT bool LocalizeStreet(DataSourceBase const & dataSource, FeatureID const & fid, osm::LocalizedStreet & result) { - EditableDataSource::FeaturesLoaderGuard g(index, fid.m_mwmId); + EditableDataSource::FeaturesLoaderGuard g(dataSource, fid.m_mwmId); FeatureType ft; if (!g.GetFeatureByIndex(fid.m_index, ft)) return false; @@ -2748,7 +2748,7 @@ WARN_UNUSED_RESULT bool LocalizeStreet(DataSourceBase const & index, FeatureID c } vector TakeSomeStreetsAndLocalize( - vector const & streets, DataSourceBase const & index) + vector const & streets, DataSourceBase const & dataSource) { vector results; @@ -2767,7 +2767,7 @@ vector TakeSomeStreetsAndLocalize( continue; osm::LocalizedStreet ls; - if (!LocalizeStreet(index, street.m_id, ls)) + if (!LocalizeStreet(dataSource, street.m_id, ls)) continue; results.emplace_back(move(ls)); @@ -2777,7 +2777,7 @@ vector TakeSomeStreetsAndLocalize( return results; } -void SetStreet(search::ReverseGeocoder const & coder, DataSourceBase const & index, +void SetStreet(search::ReverseGeocoder const & coder, DataSourceBase const & dataSource, FeatureType & ft, osm::EditableMapObject & emo) { auto const & editor = osm::Editor::Instance(); @@ -2802,7 +2802,7 @@ void SetStreet(search::ReverseGeocoder const & coder, DataSourceBase const & ind if (!featureIsInEditor && featureHasStreetInMwm) street = streetsPool[featureStreetIndex].m_name; - auto localizedStreets = TakeSomeStreetsAndLocalize(streetsPool, index); + auto localizedStreets = TakeSomeStreetsAndLocalize(streetsPool, dataSource); if (!street.empty()) { @@ -2815,7 +2815,7 @@ void SetStreet(search::ReverseGeocoder const & coder, DataSourceBase const & ind if (it != end(streetsPool)) { osm::LocalizedStreet ls; - if (!LocalizeStreet(index, it->m_id, ls)) + if (!LocalizeStreet(dataSource, it->m_id, ls)) ls.m_defaultName = street; emo.SetStreet(ls); @@ -2844,7 +2844,7 @@ void SetStreet(search::ReverseGeocoder const & coder, DataSourceBase const & ind emo.SetNearbyStreets(move(localizedStreets)); } -void SetHostingBuildingAddress(FeatureID const & hostingBuildingFid, DataSourceBase const & index, +void SetHostingBuildingAddress(FeatureID const & hostingBuildingFid, DataSourceBase const & dataSource, search::ReverseGeocoder const & coder, osm::EditableMapObject & emo) { if (!hostingBuildingFid.IsValid()) @@ -2852,7 +2852,7 @@ void SetHostingBuildingAddress(FeatureID const & hostingBuildingFid, DataSourceB FeatureType hostingBuildingFeature; - EditableDataSource::FeaturesLoaderGuard g(index, hostingBuildingFid.m_mwmId); + EditableDataSource::FeaturesLoaderGuard g(dataSource, hostingBuildingFid.m_mwmId); if (!g.GetFeatureByIndex(hostingBuildingFid.m_index, hostingBuildingFeature)) return; @@ -2877,22 +2877,22 @@ bool Framework::CreateMapObject(m2::PointD const & mercator, uint32_t const feat osm::EditableMapObject & emo) const { emo = {}; - auto const & index = m_model.GetIndex(); - MwmSet::MwmId const mwmId = index.GetMwmIdByCountryFile( + auto const & dataSource = m_model.GetDataSource(); + MwmSet::MwmId const mwmId = dataSource.GetMwmIdByCountryFile( platform::CountryFile(m_infoGetter->GetRegionCountryId(mercator))); if (!mwmId.IsAlive()) return false; GetPlatform().GetMarketingService().SendMarketingEvent(marketing::kEditorAddStart, {}); - search::ReverseGeocoder const coder(m_model.GetIndex()); + search::ReverseGeocoder const coder(m_model.GetDataSource()); vector streets; coder.GetNearbyStreets(mwmId, mercator, streets); - emo.SetNearbyStreets(TakeSomeStreetsAndLocalize(streets, m_model.GetIndex())); + emo.SetNearbyStreets(TakeSomeStreetsAndLocalize(streets, m_model.GetDataSource())); // TODO(mgsergio): Check emo is a poi. For now it is the only option. - SetHostingBuildingAddress(FindBuildingAtPoint(mercator), index, coder, emo); + SetHostingBuildingAddress(FindBuildingAtPoint(mercator), dataSource, coder, emo); return osm::Editor::Instance().CreatePoint(featureType, mercator, mwmId, emo); } @@ -2914,15 +2914,15 @@ bool Framework::GetEditableMapObject(FeatureID const & fid, osm::EditableMapObje auto const & editor = osm::Editor::Instance(); emo.SetEditableProperties(editor.GetEditableProperties(ft)); - auto const & index = m_model.GetIndex(); - search::ReverseGeocoder const coder(index); - SetStreet(coder, index, ft, emo); + auto const & dataSource = m_model.GetDataSource(); + search::ReverseGeocoder const coder(dataSource); + SetStreet(coder, dataSource, ft, emo); if (!ftypes::IsBuildingChecker::Instance()(ft) && (emo.GetHouseNumber().empty() || emo.GetStreet().m_defaultName.empty())) { SetHostingBuildingAddress(FindBuildingAtPoint(feature::GetCenter(ft)), - index, coder, emo); + dataSource, coder, emo); } return true; @@ -2946,7 +2946,7 @@ osm::Editor::SaveResult Framework::SaveEditedMapObject(osm::EditableMapObject em { auto const isCreatedFeature = editor.IsCreatedFeature(emo.GetID()); - EditableDataSource::FeaturesLoaderGuard g(m_model.GetIndex(), emo.GetID().m_mwmId); + EditableDataSource::FeaturesLoaderGuard g(m_model.GetDataSource(), emo.GetID().m_mwmId); FeatureType originalFeature; if (!isCreatedFeature) { @@ -2974,7 +2974,7 @@ osm::Editor::SaveResult Framework::SaveEditedMapObject(osm::EditableMapObject em issueLatLon = MercatorBounds::ToLatLon(feature::GetCenter(hostingBuildingFeature)); search::ReverseGeocoder::Address hostingBuildingAddress; - search::ReverseGeocoder const coder(m_model.GetIndex()); + search::ReverseGeocoder const coder(m_model.GetDataSource()); // The is no address to take from a hosting building. Fallback to simple saving. if (!coder.GetExactAddress(hostingBuildingFeature, hostingBuildingAddress)) break; @@ -3274,7 +3274,7 @@ vector Framework::GetMwmsByRect(m2::RectD const & rect, bool roug MwmSet::MwmId Framework::GetMwmIdByName(string const & name) const { - return m_model.GetIndex().GetMwmIdByCountryFile(platform::CountryFile(name)); + return m_model.GetDataSource().GetMwmIdByCountryFile(platform::CountryFile(name)); } void Framework::ReadFeatures(function const & reader, @@ -3316,7 +3316,7 @@ void Framework::InitCityFinder() { ASSERT(!m_cityFinder, ()); - m_cityFinder = make_unique(m_model.GetIndex()); + m_cityFinder = make_unique(m_model.GetDataSource()); } void Framework::InitTaxiEngine() @@ -3357,7 +3357,7 @@ void Framework::InjectViator(place_page::Info & info) return; auto const & country = GetStorage().CountryByCountryId(info.GetCountryId()); - auto const mwmId = m_model.GetIndex().GetMwmIdByCountryFile(country.GetFile()); + auto const mwmId = m_model.GetDataSource().GetMwmIdByCountryFile(country.GetFile()); if (!mwmId.IsAlive() || !mwmId.GetInfo()->IsRegistered()) return; @@ -3367,7 +3367,7 @@ void Framework::InjectViator(place_page::Info & info) static double constexpr kSearchRadiusM = 3.0; m2::RectD const rect = MercatorBounds::RectByCenterXYAndSizeInMeters(point, kSearchRadiusM); - m_model.GetIndex().ForEachInRectForMWM( + m_model.GetDataSource().ForEachInRectForMWM( [&info](FeatureType & ft) { if (ft.GetFeatureType() != feature::EGeomType::GEOM_POINT || info.IsSponsored() || !ftypes::IsViatorChecker::Instance()(ft)) diff --git a/map/framework.hpp b/map/framework.hpp index 7b081c5ce4..662a1ce512 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -311,7 +311,7 @@ public: storage::CountryInfoGetter & GetCountryInfoGetter() { return *m_infoGetter; } StorageDownloadingPolicy & GetDownloadingPolicy() { return m_storageDownloadingPolicy; } - DataSourceBase const & GetIndex() const { return m_model.GetIndex(); } + DataSourceBase const & GetDataSource() const { return m_model.GetDataSource(); } SearchAPI & GetSearchAPI(); SearchAPI const & GetSearchAPI() const; @@ -679,7 +679,7 @@ public: template void ForEachFeatureAtPoint(TFn && fn, m2::PointD const & mercator) const { - indexer::ForEachFeatureAtPoint(m_model.GetIndex(), fn, mercator, 0.0); + indexer::ForEachFeatureAtPoint(m_model.GetDataSource(), fn, mercator, 0.0); } /// Set parse to false if you don't need all feature fields ready. /// TODO(AlexZ): Refactor code which uses this method to get rid of it. diff --git a/map/map_integration_tests/interactive_search_test.cpp b/map/map_integration_tests/interactive_search_test.cpp index 5803383dc2..ebcda503bf 100644 --- a/map/map_integration_tests/interactive_search_test.cpp +++ b/map/map_integration_tests/interactive_search_test.cpp @@ -118,7 +118,7 @@ UNIT_CLASS_TEST(InteractiveSearchTest, Smoke) TEST(!stats.m_hotelDisplacementModeSet, ()); TEST_EQUAL(stats.m_numShownResults, 4, ()); - TEST(MatchResults(m_index, rules, request.Results()), ()); + TEST(MatchResults(m_dataSource, rules, request.Results()), ()); } { @@ -132,7 +132,7 @@ UNIT_CLASS_TEST(InteractiveSearchTest, Smoke) TEST(stats.m_hotelDisplacementModeSet, ()); TEST_EQUAL(stats.m_numShownResults, 4, ()); - TEST(MatchResults(m_index, rules, request.Results()), ()); + TEST(MatchResults(m_dataSource, rules, request.Results()), ()); } } @@ -161,7 +161,7 @@ UNIT_CLASS_TEST(InteractiveSearchTest, NearbyFeaturesInViewport) TestSearchRequest request(m_engine, params); request.Run(); - TEST(MatchResults(m_index, + TEST(MatchResults(m_dataSource, TRules{ExactMatch(id, cafe1), ExactMatch(id, cafe2), ExactMatch(id, cafe3)}, request.Results()), ()); @@ -175,8 +175,8 @@ UNIT_CLASS_TEST(InteractiveSearchTest, NearbyFeaturesInViewport) auto const & results = request.Results(); - TEST(MatchResults(m_index, TRules{ExactMatch(id, cafe1), ExactMatch(id, cafe3)}, results) || - MatchResults(m_index, TRules{ExactMatch(id, cafe2)}, results), + TEST(MatchResults(m_dataSource, TRules{ExactMatch(id, cafe1), ExactMatch(id, cafe3)}, results) || + MatchResults(m_dataSource, TRules{ExactMatch(id, cafe2)}, results), ()); } } diff --git a/map/map_tests/address_tests.cpp b/map/map_tests/address_tests.cpp index 2a12cc5691..2b54ef1fba 100644 --- a/map/map_tests/address_tests.cpp +++ b/map/map_tests/address_tests.cpp @@ -33,10 +33,10 @@ UNIT_TEST(ReverseGeocoder_Smoke) LocalCountryFile file = LocalCountryFile::MakeForTesting("minsk-pass"); - DataSource index; - TEST_EQUAL(index.RegisterMap(file).second, MwmSet::RegResult::Success, ()); + DataSource dataSource; + TEST_EQUAL(dataSource.RegisterMap(file).second, MwmSet::RegResult::Success, ()); - ReverseGeocoder coder(index); + ReverseGeocoder coder(dataSource); TestAddress(coder, {53.89815, 27.54265}, "улицамясникова", "32"); TestAddress(coder, {53.89953, 27.54189}, "улицанемига", "42"); diff --git a/map/map_tests/booking_filter_test.cpp b/map/map_tests/booking_filter_test.cpp index 23819d1c4b..4c4aa7bb0d 100644 --- a/map/map_tests/booking_filter_test.cpp +++ b/map/map_tests/booking_filter_test.cpp @@ -29,7 +29,7 @@ class TestMwmEnvironment : public TestWithCustomMwms, public FilterBase::Delegate { public: - DataSourceBase const & GetIndex() const override { return m_index; } + DataSourceBase const & GetDataSource() const override { return m_dataSource; } booking::Api const & GetApi() const override { return m_api; } @@ -85,7 +85,7 @@ UNIT_CLASS_TEST(TestMwmEnvironment, BookingFilter_AvailabilitySmoke) search::Results results; results.AddResult({"suggest for testing", "suggest for testing"}); search::Results expectedResults; - m_index.ForEachInRect( + m_dataSource.ForEachInRect( [&results, &expectedResults](FeatureType & ft) { search::Result::Metadata metadata; metadata.m_isSponsoredHotel = true; @@ -158,7 +158,7 @@ UNIT_CLASS_TEST(TestMwmEnvironment, BookingFilter_ProcessorSmoke) search::Results expectedAvailabilityResults; search::Results expectedDealsResults; search::Results expectedAvailableWithDeals; - m_index.ForEachInRect( + m_dataSource.ForEachInRect( [&](FeatureType & ft) { search::Result::Metadata metadata; metadata.m_isSponsoredHotel = true; @@ -202,7 +202,7 @@ UNIT_CLASS_TEST(TestMwmEnvironment, BookingFilter_ProcessorSmoke) tasks.emplace_back(Type::Deals, std::move(dealsParams)); - FilterProcessor processor(GetIndex(), GetApi()); + FilterProcessor processor(GetDataSource(), GetApi()); auto tasksCopy = tasks; processor.ApplyFilters(results, std::move(tasksCopy), ApplicationMode::Independent); diff --git a/map/map_tests/mwm_set_test.cpp b/map/map_tests/mwm_set_test.cpp index b46bc51c99..436d560949 100644 --- a/map/map_tests/mwm_set_test.cpp +++ b/map/map_tests/mwm_set_test.cpp @@ -41,20 +41,20 @@ UNIT_TEST(MwmSet_FileSystemErrors) }; MY_SCOPE_GUARD(restoreGuard, restoreFn); - DataSource index; - auto p = index.RegisterMap(localFile); + DataSource dataSource; + auto p = dataSource.RegisterMap(localFile); TEST_EQUAL(p.second, DataSource::RegResult::Success, ()); // Registering should pass ok. - TEST(index.GetMwmIdByCountryFile(file) != DataSource::MwmId(), ()); + TEST(dataSource.GetMwmIdByCountryFile(file) != DataSource::MwmId(), ()); // Getting handle causes feature offsets index building which should fail // because of write permissions. - TEST(!index.GetMwmHandleById(p.first).IsAlive(), ()); + TEST(!dataSource.GetMwmHandleById(p.first).IsAlive(), ()); // Map is automatically deregistered after the fail. vector> infos; - index.GetMwmsInfo(infos); + dataSource.GetMwmsInfo(infos); TEST(infos.empty(), ()); } #endif diff --git a/map/map_tests/search_api_tests.cpp b/map/map_tests/search_api_tests.cpp index b21fad01f5..802379f440 100644 --- a/map/map_tests/search_api_tests.cpp +++ b/map/map_tests/search_api_tests.cpp @@ -61,7 +61,7 @@ class SearchAPITest : public generator::tests_support::TestWithCustomMwms public: SearchAPITest() : m_infoGetter(CountryInfoReader::CreateCountryInfoReader(GetPlatform())) - , m_api(m_index, m_storage, *m_infoGetter, m_delegate) + , m_api(m_dataSource, m_storage, *m_infoGetter, m_delegate) { } @@ -107,7 +107,7 @@ UNIT_CLASS_TEST(SearchAPITest, MultipleViewportsRequests) if (stage == 0) { Rules const rules = {ExactMatch(id, cafe1), ExactMatch(id, cafe2)}; - TEST(MatchResults(m_index, rules, results), ()); + TEST(MatchResults(m_dataSource, rules, results), ()); promise0.set_value(); } @@ -115,7 +115,7 @@ UNIT_CLASS_TEST(SearchAPITest, MultipleViewportsRequests) { TEST_EQUAL(stage, 1, ()); Rules const rules = {ExactMatch(id, cafe3), ExactMatch(id, cafe4)}; - TEST(MatchResults(m_index, rules, results), ()); + TEST(MatchResults(m_dataSource, rules, results), ()); promise1.set_value(); } diff --git a/map/routing_manager.cpp b/map/routing_manager.cpp index 6ee463daf2..ab60aa2e09 100644 --- a/map/routing_manager.cpp +++ b/map/routing_manager.cpp @@ -364,8 +364,8 @@ RouterType RoutingManager::GetLastUsedRouter() const void RoutingManager::SetRouterImpl(RouterType type) { - auto const indexGetterFn = m_callbacks.m_indexGetter; - CHECK(indexGetterFn, ("Type:", type)); + auto const dataSourceGetterFn = m_callbacks.m_dataSourceGetter; + CHECK(dataSourceGetterFn, ("Type:", type)); VehicleType const vehicleType = GetVehicleType(type); @@ -380,10 +380,10 @@ void RoutingManager::SetRouterImpl(RouterType type) auto numMwmIds = make_shared(); m_delegate.RegisterCountryFilesOnRoute(numMwmIds); - auto & index = m_callbacks.m_indexGetter(); + auto & dataSource = m_callbacks.m_dataSourceGetter(); auto localFileChecker = [this](string const & countryFile) -> bool { - MwmSet::MwmId const mwmId = m_callbacks.m_indexGetter().GetMwmIdByCountryFile( + MwmSet::MwmId const mwmId = m_callbacks.m_dataSourceGetter().GetMwmIdByCountryFile( platform::CountryFile(countryFile)); if (!mwmId.IsAlive()) return false; @@ -399,7 +399,7 @@ void RoutingManager::SetRouterImpl(RouterType type) auto router = make_unique(vehicleType, m_loadAltitudes, m_callbacks.m_countryParentNameGetterFn, countryFileGetter, getMwmRectByName, numMwmIds, MakeNumMwmTree(*numMwmIds, m_callbacks.m_countryInfoGetter()), - m_routingSession, index); + m_routingSession, dataSource); m_routingSession.SetRoutingSettings(GetRoutingSettings(vehicleType)); m_routingSession.SetRouter(move(router), move(fetcher)); @@ -455,7 +455,7 @@ void RoutingManager::InsertRoute(Route const & route) m_delegate.RegisterCountryFilesOnRoute(numMwmIds); auto getMwmId = [this, numMwmIds](routing::NumMwmId numMwmId) { - return m_callbacks.m_indexGetter().GetMwmIdByCountryFile(numMwmIds->GetFile(numMwmId)); + return m_callbacks.m_dataSourceGetter().GetMwmIdByCountryFile(numMwmIds->GetFile(numMwmId)); }; transitRouteDisplay = make_shared(*m_transitReadManager, getMwmId, m_callbacks.m_stringsBundleGetter, @@ -904,10 +904,10 @@ void RoutingManager::CheckLocationForRouting(location::GpsInfo const & info) if (!IsRoutingActive()) return; - auto const featureIndexGetterFn = m_callbacks.m_indexGetter; - ASSERT(featureIndexGetterFn, ()); + auto const featureDataSourceGetterFn = m_callbacks.m_dataSourceGetter; + ASSERT(featureDataSourceGetterFn, ()); RoutingSession::State const state = - m_routingSession.OnLocationPositionChanged(info, featureIndexGetterFn()); + m_routingSession.OnLocationPositionChanged(info, featureDataSourceGetterFn()); if (state == RoutingSession::RouteNeedRebuild) { m_routingSession.RebuildRoute( diff --git a/map/routing_manager.hpp b/map/routing_manager.hpp index da3b5b9bf7..5e6ed26bca 100644 --- a/map/routing_manager.hpp +++ b/map/routing_manager.hpp @@ -67,22 +67,24 @@ public: struct Callbacks { - using IndexGetterFn = std::function; + using DataSourceGetterFn = std::function; using CountryInfoGetterFn = std::function; using CountryParentNameGetterFn = std::function; using GetStringsBundleFn = std::function; - template - Callbacks(IndexGetter && featureIndexGetter, CountryInfoGetter && countryInfoGetter, - CountryParentNameGetter && countryParentNameGetter, StringsBundleGetter && stringsBundleGetter) - : m_indexGetter(std::forward(featureIndexGetter)) + template + Callbacks(DataSourceGetter && dataSourceGetter, CountryInfoGetter && countryInfoGetter, + CountryParentNameGetter && countryParentNameGetter, + StringsBundleGetter && stringsBundleGetter) + : m_dataSourceGetter(std::forward(dataSourceGetter)) , m_countryInfoGetter(std::forward(countryInfoGetter)) , m_countryParentNameGetterFn(std::forward(countryParentNameGetter)) , m_stringsBundleGetter(std::forward(stringsBundleGetter)) - {} + { + } - IndexGetterFn m_indexGetter; + DataSourceGetterFn m_dataSourceGetter; CountryInfoGetterFn m_countryInfoGetter; CountryParentNameGetterFn m_countryParentNameGetterFn; GetStringsBundleFn m_stringsBundleGetter; diff --git a/map/search_api.cpp b/map/search_api.cpp index f70e1b7fb5..6a8a41667b 100644 --- a/map/search_api.cpp +++ b/map/search_api.cpp @@ -116,13 +116,13 @@ private: }; } // namespace -SearchAPI::SearchAPI(DataSourceBase & index, storage::Storage const & storage, +SearchAPI::SearchAPI(DataSourceBase & dataSource, storage::Storage const & storage, storage::CountryInfoGetter const & infoGetter, Delegate & delegate) - : m_index(index) + : m_dataSource(dataSource) , m_storage(storage) , m_infoGetter(infoGetter) , m_delegate(delegate) - , m_engine(m_index, GetDefaultCategories(), m_infoGetter, + , m_engine(m_dataSource, GetDefaultCategories(), m_infoGetter, Engine::Params(languages::GetCurrentTwine() /* locale */, 1 /* params.m_numThreads */)) { } @@ -260,7 +260,7 @@ bool SearchAPI::SearchInDownloader(storage::DownloaderSearchParams const & param p.m_needHighlighting = false; p.m_onResults = DownloaderSearchCallback(static_cast(*this), - m_index, m_infoGetter, m_storage, params); + m_dataSource, m_infoGetter, m_storage, params); return Search(p, true /* forceSearch */); } diff --git a/map/search_api.hpp b/map/search_api.hpp index f06c5c234f..257bad307f 100644 --- a/map/search_api.hpp +++ b/map/search_api.hpp @@ -87,7 +87,7 @@ public: virtual search::ProductInfo GetProductInfo(search::Result const & result) const { return {}; }; }; - SearchAPI(DataSourceBase & index, storage::Storage const & storage, + SearchAPI(DataSourceBase & dataSource, storage::Storage const & storage, storage::CountryInfoGetter const & infoGetter, Delegate & delegate); virtual ~SearchAPI() = default; @@ -155,7 +155,7 @@ private: bool QueryMayBeSkipped(search::SearchParams const & prevParams, search::SearchParams const & currParams) const; - DataSourceBase & m_index; + DataSourceBase & m_dataSource; storage::Storage const & m_storage; storage::CountryInfoGetter const & m_infoGetter; Delegate & m_delegate; diff --git a/map/transit/transit_reader.cpp b/map/transit/transit_reader.cpp index 9f77102c0c..393c733e4a 100644 --- a/map/transit/transit_reader.cpp +++ b/map/transit/transit_reader.cpp @@ -58,7 +58,7 @@ void ReadTransitTask::Init(uint64_t id, MwmSet::MwmId const & mwmId, void ReadTransitTask::Do() { - MwmSet::MwmHandle handle = m_index.GetMwmHandleById(m_mwmId); + MwmSet::MwmHandle handle = m_dataSource.GetMwmHandleById(m_mwmId); if (!handle.IsAlive()) { // It's possible that mwm handle is not alive because mwm may be removed after @@ -137,9 +137,9 @@ unique_ptr && ReadTransitTask::GetTransitInfo() return move(m_transitInfo); } -TransitReadManager::TransitReadManager(DataSourceBase & index, TReadFeaturesFn const & readFeaturesFn, +TransitReadManager::TransitReadManager(DataSourceBase & dataSource, TReadFeaturesFn const & readFeaturesFn, GetMwmsByRectFn const & getMwmsByRectFn) - : m_index(index) + : m_dataSource(dataSource) , m_readFeaturesFn(readFeaturesFn) , m_getMwmsByRectFn(getMwmsByRectFn) { @@ -303,7 +303,7 @@ bool TransitReadManager::GetTransitDisplayInfo(TransitDisplayInfos & transitDisp for (auto & mwmTransitPair : transitDisplayInfos) { auto const & mwmId = mwmTransitPair.first; - auto task = my::make_unique(m_index, m_readFeaturesFn); + auto task = my::make_unique(m_dataSource, m_readFeaturesFn); task->Init(groupId, mwmId, move(mwmTransitPair.second)); transitTasks[mwmId] = move(task); } diff --git a/map/transit/transit_reader.hpp b/map/transit/transit_reader.hpp index 3eaabb7e42..5644763b58 100644 --- a/map/transit/transit_reader.hpp +++ b/map/transit/transit_reader.hpp @@ -31,9 +31,9 @@ using TReadFeaturesFn = std::function(m2::RectD const &)>; - TransitReadManager(DataSourceBase & index, TReadFeaturesFn const & readFeaturesFn, + TransitReadManager(DataSourceBase & dataSource, TReadFeaturesFn const & readFeaturesFn, GetMwmsByRectFn const & getMwmsByRectFn); ~TransitReadManager(); @@ -113,7 +113,7 @@ private: uint64_t m_nextTasksGroupId = 0; std::map m_tasksGroups; - DataSourceBase & m_index; + DataSourceBase & m_dataSource; TReadFeaturesFn m_readFeaturesFn; df::DrapeEngineSafePtr m_drapeEngine; diff --git a/openlr/candidate_points_getter.cpp b/openlr/candidate_points_getter.cpp index b0bad2cbe5..6c110ae336 100644 --- a/openlr/candidate_points_getter.cpp +++ b/openlr/candidate_points_getter.cpp @@ -30,7 +30,7 @@ void CandidatePointsGetter::GetJunctionPointCandidates(m2::PointD const & p, scales::GetUpperScale()); }; - m_index.ForEachInRect(selectCandidates, rect, scales::GetUpperScale()); + m_dataSource.ForEachInRect(selectCandidates, rect, scales::GetUpperScale()); // TODO: Move this to a separate stage. // 1030292476 Does not match. Some problem occur with points. diff --git a/openlr/candidate_points_getter.hpp b/openlr/candidate_points_getter.hpp index f8252732a5..618ddea02f 100644 --- a/openlr/candidate_points_getter.hpp +++ b/openlr/candidate_points_getter.hpp @@ -17,10 +17,10 @@ class CandidatePointsGetter { public: CandidatePointsGetter(size_t const maxJunctionCandidates, size_t const maxProjectionCandidates, - DataSourceBase const & index, Graph & graph) + DataSourceBase const & dataSource, Graph & graph) : m_maxJunctionCandidates(maxJunctionCandidates) , m_maxProjectionCandidates(maxProjectionCandidates) - , m_index(index) + , m_dataSource(dataSource) , m_graph(graph) { } @@ -38,7 +38,7 @@ private: size_t const m_maxJunctionCandidates; size_t const m_maxProjectionCandidates; - DataSourceBase const & m_index; + DataSourceBase const & m_dataSource; Graph & m_graph; }; } // namespace openlr diff --git a/openlr/decoded_path.cpp b/openlr/decoded_path.cpp index 3e8bce2bea..33642c2567 100644 --- a/openlr/decoded_path.cpp +++ b/openlr/decoded_path.cpp @@ -45,11 +45,11 @@ void LatLonFromXML(pugi::xml_node const & node, ms::LatLon & latLon) latLon.lon = node.child("lon").text().as_double(); } -void FeatureIdFromXML(pugi::xml_node const & node, DataSourceBase const & index, FeatureID & fid) +void FeatureIdFromXML(pugi::xml_node const & node, DataSourceBase const & dataSource, FeatureID & fid) { THROW_IF_NODE_IS_EMPTY(node, openlr::DecodedPathLoadError, ("Can't parse CountryName")); auto const countryName = node.child("CountryName").text().as_string(); - fid.m_mwmId = index.GetMwmIdByCountryFile(platform::CountryFile(countryName)); + fid.m_mwmId = dataSource.GetMwmIdByCountryFile(platform::CountryFile(countryName)); CHECK(fid.m_mwmId.IsAlive(), ("Can't get mwm id for country", countryName)); fid.m_index = node.child("Index").text().as_uint(); } @@ -109,7 +109,7 @@ void WriteAsMappingForSpark(std::ostream & ost, std::vector const & } } -void PathFromXML(pugi::xml_node const & node, DataSourceBase const & index, Path & p) +void PathFromXML(pugi::xml_node const & node, DataSourceBase const & dataSource, Path & p) { auto const edges = node.select_nodes("RoadEdge"); for (auto const xmlE : edges) @@ -117,7 +117,7 @@ void PathFromXML(pugi::xml_node const & node, DataSourceBase const & index, Path auto e = xmlE.node(); FeatureID fid; - FeatureIdFromXML(e.child("FeatureID"), index, fid); + FeatureIdFromXML(e.child("FeatureID"), dataSource, fid); auto const isForward = IsForwardFromXML(e.child("IsForward")); auto const segmentId = SegmentIdFromXML(e.child("SegmentId")); diff --git a/openlr/decoded_path.hpp b/openlr/decoded_path.hpp index a6a9395108..18875937f3 100644 --- a/openlr/decoded_path.hpp +++ b/openlr/decoded_path.hpp @@ -33,7 +33,7 @@ struct DecodedPath void WriteAsMappingForSpark(std::string const & fileName, std::vector const & paths); void WriteAsMappingForSpark(std::ostream & ost, std::vector const & paths); -void PathFromXML(pugi::xml_node const & node, DataSourceBase const & index, Path & path); +void PathFromXML(pugi::xml_node const & node, DataSourceBase const & dataSource, Path & path); void PathToXML(Path const & path, pugi::xml_node & node); } // namespace openlr diff --git a/openlr/graph.cpp b/openlr/graph.cpp index 1e831166ef..c2da01d639 100644 --- a/openlr/graph.cpp +++ b/openlr/graph.cpp @@ -30,8 +30,8 @@ void GetRegularEdges(Junction const & junction, IRoadGraph const & graph, } } // namespace -Graph::Graph(DataSourceBase const & index, shared_ptr carModelFactory) - : m_graph(index, IRoadGraph::Mode::ObeyOnewayTag, carModelFactory) +Graph::Graph(DataSourceBase const & dataSource, shared_ptr carModelFactory) + : m_graph(dataSource, IRoadGraph::Mode::ObeyOnewayTag, carModelFactory) { } diff --git a/openlr/graph.hpp b/openlr/graph.hpp index 9db2d5d50c..7a5863a4d2 100644 --- a/openlr/graph.hpp +++ b/openlr/graph.hpp @@ -24,7 +24,7 @@ public: using EdgeVector = routing::FeaturesRoadGraph::TEdgeVector; using Junction = routing::Junction; - Graph(DataSourceBase const & index, std::shared_ptr carModelFactory); + Graph(DataSourceBase const & dataSource, std::shared_ptr carModelFactory); // Appends edges such as that edge.GetStartJunction() == junction to the |edges|. void GetOutgoingEdges(routing::Junction const & junction, EdgeVector & edges); diff --git a/openlr/openlr_decoder.cpp b/openlr/openlr_decoder.cpp index fb211aa596..42adfb9689 100644 --- a/openlr/openlr_decoder.cpp +++ b/openlr/openlr_decoder.cpp @@ -79,9 +79,9 @@ struct alignas(kCacheLineSize) Stats uint32_t m_routesHandled = 0; }; -bool IsRealVertex(m2::PointD const & p, FeatureID const & fid, DataSource const & index) +bool IsRealVertex(m2::PointD const & p, FeatureID const & fid, DataSource const & dataSource) { - DataSource::FeaturesLoaderGuard g(index, fid.m_mwmId); + DataSource::FeaturesLoaderGuard g(dataSource, fid.m_mwmId); auto const ft = g.GetOriginalFeatureByIndex(fid.m_index); bool matched = false; ft->ForEachPoint( @@ -93,20 +93,20 @@ bool IsRealVertex(m2::PointD const & p, FeatureID const & fid, DataSource const return matched; }; -void ExpandFake(Graph::EdgeVector & path, Graph::EdgeVector::iterator edgeIt, DataSource const & index, +void ExpandFake(Graph::EdgeVector & path, Graph::EdgeVector::iterator edgeIt, DataSource const & dataSource, Graph & g) { if (!edgeIt->IsFake()) return; Graph::EdgeVector edges; - if (IsRealVertex(edgeIt->GetStartPoint(), edgeIt->GetFeatureId(), index)) + if (IsRealVertex(edgeIt->GetStartPoint(), edgeIt->GetFeatureId(), dataSource)) { g.GetRegularOutgoingEdges(edgeIt->GetStartJunction(), edges); } else { - ASSERT(IsRealVertex(edgeIt->GetEndPoint(), edgeIt->GetFeatureId(), index), ()); + ASSERT(IsRealVertex(edgeIt->GetEndPoint(), edgeIt->GetFeatureId(), dataSource), ()); g.GetRegularIngoingEdges(edgeIt->GetEndJunction(), edges); } @@ -128,14 +128,14 @@ void ExpandFake(Graph::EdgeVector & path, Graph::EdgeVector::iterator edgeIt, Da path.erase(edgeIt); }; -void ExpandFakes(DataSource const & index, Graph & g, Graph::EdgeVector & path) +void ExpandFakes(DataSource const & dataSource, Graph & g, Graph::EdgeVector & path) { ASSERT(!path.empty(), ()); - ExpandFake(path, begin(path), index, g); + ExpandFake(path, begin(path), dataSource, g); if (path.empty()) return; - ExpandFake(path, --end(path), index, g); + ExpandFake(path, --end(path), dataSource, g); } // Returns an iterator pointing to the first edge that should not be cut off. @@ -189,9 +189,9 @@ void CopyWithoutOffsets(InputIterator const start, InputIterator const stop, Out class SegmentsDecoderV1 { public: - SegmentsDecoderV1(DataSourceBase const & index, unique_ptr cmf) - : m_roadGraph(index, IRoadGraph::Mode::ObeyOnewayTag, move(cmf)) - , m_infoGetter(index) + SegmentsDecoderV1(DataSourceBase const & dataSource, unique_ptr cmf) + : m_roadGraph(dataSource, IRoadGraph::Mode::ObeyOnewayTag, move(cmf)) + , m_infoGetter(dataSource) , m_router(m_roadGraph, m_infoGetter) { } @@ -258,8 +258,8 @@ private: class SegmentsDecoderV2 { public: - SegmentsDecoderV2(DataSource const & index, unique_ptr cmf) - : m_index(index), m_graph(index, move(cmf)), m_infoGetter(index) + SegmentsDecoderV2(DataSource const & dataSource, unique_ptr cmf) + : m_dataSource(dataSource), m_graph(dataSource, move(cmf)), m_infoGetter(dataSource) { } @@ -279,7 +279,7 @@ public: lineCandidates.reserve(points.size()); LOG(LDEBUG, ("Decoding segment:", segment.m_segmentId, "with", points.size(), "points")); - CandidatePointsGetter pointsGetter(kMaxJunctionCandidates, kMaxProjectionCandidates, m_index, + CandidatePointsGetter pointsGetter(kMaxJunctionCandidates, kMaxProjectionCandidates, m_dataSource, m_graph); CandidatePathsGetter pathsGetter(pointsGetter, m_graph, m_infoGetter, stat); @@ -320,7 +320,7 @@ public: return false; } - ExpandFakes(m_index, m_graph, route); + ExpandFakes(m_dataSource, m_graph, route); ASSERT(none_of(begin(route), end(route), mem_fn(&Graph::Edge::IsFake)), (segment.m_segmentId)); CopyWithoutOffsets(begin(route), end(route), back_inserter(path.m_path), positiveOffsetM, negativeOffsetM); @@ -336,7 +336,7 @@ public: } private: - DataSource const & m_index; + DataSource const & m_dataSource; Graph m_graph; RoadInfoGetter m_infoGetter; }; @@ -378,9 +378,9 @@ bool OpenLRDecoder::SegmentsFilter::Matches(LinearSegment const & segment) const } // OpenLRDecoder ----------------------------------------------------------------------------- -OpenLRDecoder::OpenLRDecoder(vector const & indexes, +OpenLRDecoder::OpenLRDecoder(vector const & dataSources, CountryParentNameGetter const & countryParentNameGetter) - : m_indexes(indexes), m_countryParentNameGetter(countryParentNameGetter) + : m_dataSources(dataSources), m_countryParentNameGetter(countryParentNameGetter) { } @@ -400,14 +400,14 @@ template void OpenLRDecoder::Decode(vector const & segments, uint32_t const numThreads, vector & paths) { - auto const worker = [&segments, &paths, numThreads, this](size_t threadNum, DataSource const & index, + auto const worker = [&segments, &paths, numThreads, this](size_t threadNum, DataSource const & dataSource, Stats & stat) { size_t constexpr kBatchSize = GetOptimalBatchSize(); size_t constexpr kProgressFrequency = 100; size_t const numSegments = segments.size(); - Decoder decoder(index, make_unique(m_countryParentNameGetter)); + Decoder decoder(dataSource, make_unique(m_countryParentNameGetter)); my::Timer timer; for (size_t i = threadNum * kBatchSize; i < numSegments; i += numThreads * kBatchSize) { @@ -430,9 +430,9 @@ void OpenLRDecoder::Decode(vector const & segments, vector stats(numThreads); vector workers; for (size_t i = 1; i < numThreads; ++i) - workers.emplace_back(worker, i, ref(m_indexes[i]), ref(stats[i])); + workers.emplace_back(worker, i, ref(m_dataSources[i]), ref(stats[i])); - worker(0 /* threadNum */, m_indexes[0], stats[0]); + worker(0 /* threadNum */, m_dataSources[0], stats[0]); for (auto & worker : workers) worker.join(); diff --git a/openlr/openlr_decoder.hpp b/openlr/openlr_decoder.hpp index 0fef1ec57b..f893217718 100644 --- a/openlr/openlr_decoder.hpp +++ b/openlr/openlr_decoder.hpp @@ -40,7 +40,7 @@ public: bool const m_multipointsOnly; }; - OpenLRDecoder(std::vector const & indexes, + OpenLRDecoder(std::vector const & dataSources, CountryParentNameGetter const & countryParentNameGetter); // Maps partner segments to mwm paths. |segments| should be sorted by partner id. @@ -55,7 +55,7 @@ private: void Decode(std::vector const & segments, uint32_t const numThreads, std::vector & paths); - std::vector const & m_indexes; + std::vector const & m_dataSources; CountryParentNameGetter m_countryParentNameGetter; }; } // namespace openlr diff --git a/openlr/openlr_match_quality/openlr_assessment_tool/mainwindow.cpp b/openlr/openlr_match_quality/openlr_assessment_tool/mainwindow.cpp index cc8800a49d..8cb93fc125 100644 --- a/openlr/openlr_match_quality/openlr_assessment_tool/mainwindow.cpp +++ b/openlr/openlr_match_quality/openlr_assessment_tool/mainwindow.cpp @@ -124,8 +124,8 @@ class PointsControllerDelegate : public PointsControllerDelegateBase public: PointsControllerDelegate(Framework & framework) : m_framework(framework) - , m_index(framework.GetIndex()) - , m_roadGraph(m_index, routing::IRoadGraph::Mode::ObeyOnewayTag, + , m_dataSource(framework.GetDataSource()) + , m_roadGraph(m_dataSource, routing::IRoadGraph::Mode::ObeyOnewayTag, make_unique(storage::CountryParentGetter{})) { } @@ -157,7 +157,7 @@ public: ft.ForEachPoint(pushPoint, scales::GetUpperScale()); }; - m_index.ForEachInRect(pushFeaturePoints, rect, scales::GetUpperScale()); + m_dataSource.ForEachInRect(pushFeaturePoints, rect, scales::GetUpperScale()); return points; } @@ -168,7 +168,7 @@ public: std::vector points; m2::PointD pointOnFt; - indexer::ForEachFeatureAtPoint(m_index, [&points, &p, &pointOnFt](FeatureType & ft) { + indexer::ForEachFeatureAtPoint(m_dataSource, [&points, &p, &pointOnFt](FeatureType & ft) { if (ft.GetFeatureType() != feature::GEOM_LINE) return; @@ -229,7 +229,7 @@ public: private: Framework & m_framework; - DataSourceBase const & m_index; + DataSourceBase const & m_dataSource; routing::FeaturesRoadGraph m_roadGraph; }; } // namespace @@ -309,7 +309,7 @@ MainWindow::MainWindow(Framework & framework) void MainWindow::CreateTrafficPanel(string const & dataFilePath) { m_trafficMode = new TrafficMode(dataFilePath, - m_framework.GetIndex(), + m_framework.GetDataSource(), make_unique(m_framework), make_unique(m_framework)); 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 966c22a8e0..141507a8fd 100644 --- a/openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.cpp +++ b/openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.cpp @@ -103,12 +103,12 @@ namespace openlr { // TrafficMode ------------------------------------------------------------------------------------- TrafficMode::TrafficMode(std::string const & dataFileName, - DataSourceBase const & index, + DataSourceBase const & dataSource, std::unique_ptr drawerDelegate, std::unique_ptr pointsDelegate, QObject * parent) : QAbstractTableModel(parent) - , m_index(index) + , m_dataSource(dataSource) , m_drawerDelegate(move(drawerDelegate)) , m_pointsDelegate(move(pointsDelegate)) { @@ -146,11 +146,11 @@ TrafficMode::TrafficMode(std::string const & dataFileName, MYTHROW(TrafficModeError, ("An error occured while parsing: can't parse segment")); if (auto const route = xmlSegment.child("Route")) - openlr::PathFromXML(route, m_index, matchedPath); + openlr::PathFromXML(route, m_dataSource, matchedPath); if (auto const route = xmlSegment.child("FakeRoute")) - openlr::PathFromXML(route, m_index, fakePath); + openlr::PathFromXML(route, m_dataSource, fakePath); if (auto const route = xmlSegment.child("GoldenRoute")) - openlr::PathFromXML(route, m_index, goldenPath); + openlr::PathFromXML(route, m_dataSource, goldenPath); m_segments.emplace_back(segment, matchedPath, fakePath, goldenPath, partnerSegmentXML); if (auto const status = xmlSegment.child("Ignored")) diff --git a/openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.hpp b/openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.hpp index 1b1684df1b..42ad40cd24 100644 --- a/openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.hpp +++ b/openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.hpp @@ -22,7 +22,6 @@ #include #include -class Index; class QItemSelection; class Selection; @@ -69,7 +68,7 @@ class TrafficMode : public QAbstractTableModel public: // TODO(mgsergio): Check we are on the right mwm. I.e. right mwm version and everything. TrafficMode(std::string const & dataFileName, - DataSourceBase const & index, + DataSourceBase const & dataSource, std::unique_ptr drawerDelegate, std::unique_ptr pointsDelegate, QObject * parent = Q_NULLPTR); @@ -115,7 +114,7 @@ private: void HandlePoint(m2::PointD clickPoint, Qt::MouseButton const button); bool StartBuildingPathChecks() const; - DataSourceBase const & m_index; + DataSourceBase const & m_dataSource; std::vector m_segments; // Non-owning pointer to an element of m_segments. SegmentCorrespondence * m_currentSegment = nullptr; diff --git a/openlr/openlr_stat/openlr_stat.cpp b/openlr/openlr_stat/openlr_stat.cpp index 351662cfa9..705d1d17d0 100644 --- a/openlr/openlr_stat/openlr_stat.cpp +++ b/openlr/openlr_stat/openlr_stat.cpp @@ -58,7 +58,7 @@ int32_t const kMinNumThreads = 1; int32_t const kMaxNumThreads = 128; int32_t const kHandleAllSegments = -1; -void LoadIndexes(std::string const & pathToMWMFolder, std::vector & indexes) +void LoadDataSources(std::string const & pathToMWMFolder, std::vector & dataSources) { CHECK(Platform::IsDirectory(pathToMWMFolder), (pathToMWMFolder, "must be a directory.")); @@ -67,8 +67,8 @@ void LoadIndexes(std::string const & pathToMWMFolder, std::vector & CHECK(!files.empty(), (pathToMWMFolder, "Contains no .mwm files.")); - size_t const numIndexes = indexes.size(); - std::vector numCountries(numIndexes); + size_t const numDataSources = dataSources.size(); + std::vector numCountries(numDataSources); for (auto const & fileName : files) { @@ -82,9 +82,9 @@ void LoadIndexes(std::string const & pathToMWMFolder, std::vector & try { localFile.SyncWithDisk(); - for (size_t i = 0; i < numIndexes; ++i) + for (size_t i = 0; i < numDataSources; ++i) { - auto const result = indexes[i].RegisterMap(localFile); + auto const result = dataSources[i].RegisterMap(localFile); CHECK_EQUAL(result.second, MwmSet::RegResult::Success, ("Can't register mwm:", localFile)); auto const & info = result.first.GetInfo(); @@ -98,7 +98,7 @@ void LoadIndexes(std::string const & pathToMWMFolder, std::vector & } } - for (size_t i = 0; i < numIndexes; ++i) + for (size_t i = 0; i < numDataSources; ++i) { if (numCountries[i] == 0) LOG(LWARNING, ("No countries for thread", i)); @@ -259,10 +259,10 @@ int main(int argc, char * argv[]) auto const numThreads = static_cast(FLAGS_num_threads); - std::vector indexes(numThreads); - LoadIndexes(FLAGS_mwms_path, indexes); + std::vector dataSources(numThreads); + LoadDataSources(FLAGS_mwms_path, dataSources); - OpenLRDecoder decoder(indexes, storage::CountryParentGetter(FLAGS_countries_filename, + OpenLRDecoder decoder(dataSources, storage::CountryParentGetter(FLAGS_countries_filename, GetPlatform().ResourcesDir())); pugi::xml_document document; diff --git a/openlr/openlr_tests/decoded_path_test.cpp b/openlr/openlr_tests/decoded_path_test.cpp index 24a73e291b..9f1753bb21 100644 --- a/openlr/openlr_tests/decoded_path_test.cpp +++ b/openlr/openlr_tests/decoded_path_test.cpp @@ -65,13 +65,13 @@ void RoughJunctionsInPath(openlr::Path & p) e = RoughEdgeJunctions(e); } -void TestSerializeDeserialize(openlr::Path const & path, DataSource const & index) +void TestSerializeDeserialize(openlr::Path const & path, DataSource const & dataSource) { pugi::xml_document doc; openlr::PathToXML(path, doc); openlr::Path restoredPath; - openlr::PathFromXML(doc, index, restoredPath); + openlr::PathFromXML(doc, dataSource, restoredPath); // Fix MercatorBounds::From/ToLatLon floating point error // for we could use TEST_EQUAL on result. @@ -133,25 +133,25 @@ void WithRoad(vector const & points, Func && fn) builder.Add(TestRoad(points, "Interstate 60", "en")); } - DataSource index; - auto const regResult = index.RegisterMap(country); + DataSource dataSource; + auto const regResult = dataSource.RegisterMap(country); TEST_EQUAL(regResult.second, MwmSet::RegResult::Success, ()); - MwmSet::MwmHandle mwmHandle = index.GetMwmHandleById(regResult.first); + MwmSet::MwmHandle mwmHandle = dataSource.GetMwmHandleById(regResult.first); TEST(mwmHandle.IsAlive(), ()); - DataSource::FeaturesLoaderGuard const guard(index, regResult.first); + DataSource::FeaturesLoaderGuard const guard(dataSource, regResult.first); FeatureType road; TEST(guard.GetFeatureByIndex(0, road), ()); road.ParseEverything(); - fn(index, road); + fn(dataSource, road); } UNIT_TEST(MakePath_Test) { std::vector const points{{0, 0}, {0, 1}, {1, 0}, {1, 1}}; - WithRoad(points, [&points](DataSource const & index, FeatureType & road) { + WithRoad(points, [&points](DataSource const & dataSource, FeatureType & road) { auto const & id = road.GetID(); { openlr::Path const expected{ @@ -182,14 +182,14 @@ UNIT_TEST(MakePath_Test) UNIT_TEST(PathSerializeDeserialize_Test) { - WithRoad({{0, 0}, {0, 1}, {1, 0}, {1, 1}}, [](DataSource const & index, FeatureType & road) { + WithRoad({{0, 0}, {0, 1}, {1, 0}, {1, 1}}, [](DataSource const & dataSource, FeatureType & road) { { auto const path = MakePath(road, true /* forward */); - TestSerializeDeserialize(path, index); + TestSerializeDeserialize(path, dataSource); } { auto const path = MakePath(road, false /* forward */); - TestSerializeDeserialize(path, index); + TestSerializeDeserialize(path, dataSource); } }); } diff --git a/openlr/road_info_getter.cpp b/openlr/road_info_getter.cpp index 67ee14b06c..96ffac93aa 100644 --- a/openlr/road_info_getter.cpp +++ b/openlr/road_info_getter.cpp @@ -10,7 +10,10 @@ namespace openlr { -RoadInfoGetter::RoadInfoGetter(DataSourceBase const & index) : m_index(index), m_c(classif()) {} +RoadInfoGetter::RoadInfoGetter(DataSourceBase const & dataSource) + : m_dataSource(dataSource), m_c(classif()) +{ +} RoadInfoGetter::RoadInfo RoadInfoGetter::Get(FeatureID const & fid) { @@ -18,7 +21,7 @@ RoadInfoGetter::RoadInfo RoadInfoGetter::Get(FeatureID const & fid) if (it != end(m_cache)) return it->second; - DataSource::FeaturesLoaderGuard g(m_index, fid.m_mwmId); + DataSource::FeaturesLoaderGuard g(m_dataSource, fid.m_mwmId); FeatureType ft; CHECK(g.GetOriginalFeatureByIndex(fid.m_index, ft), ()); diff --git a/openlr/road_info_getter.hpp b/openlr/road_info_getter.hpp index 4badf247c2..45c7f69060 100644 --- a/openlr/road_info_getter.hpp +++ b/openlr/road_info_getter.hpp @@ -28,7 +28,7 @@ public: FormOfWay m_fow = FormOfWay::NotAValue; }; - RoadInfoGetter(DataSourceBase const & index); + RoadInfoGetter(DataSourceBase const & dataSource); RoadInfo Get(FeatureID const & fid); @@ -36,7 +36,7 @@ public: FunctionalRoadClass GetFunctionalRoadClass(feature::TypesHolder const & types) const; FormOfWay GetFormOfWay(feature::TypesHolder const & types) const; - DataSourceBase const & m_index; + DataSourceBase const & m_dataSource; Classificator const & m_c; TrunkChecker const m_trunkChecker; diff --git a/routing/bicycle_directions.cpp b/routing/bicycle_directions.cpp index ba9ce9c40c..641d1e21ea 100644 --- a/routing/bicycle_directions.cpp +++ b/routing/bicycle_directions.cpp @@ -158,8 +158,8 @@ bool BicycleDirectionsEngine::AdjacentEdges::IsAlmostEqual(AdjacentEdges const & } // BicycleDirectionsEngine ------------------------------------------------------------------------ -BicycleDirectionsEngine::BicycleDirectionsEngine(DataSourceBase const & index, shared_ptr numMwmIds) - : m_index(index), m_numMwmIds(numMwmIds) +BicycleDirectionsEngine::BicycleDirectionsEngine(DataSourceBase const & dataSource, shared_ptr numMwmIds) + : m_dataSource(dataSource), m_numMwmIds(numMwmIds) { CHECK(m_numMwmIds, ()); } @@ -213,7 +213,7 @@ bool BicycleDirectionsEngine::Generate(IndexRoadGraph const & graph, vectorGetId()) - m_loader = make_unique(m_index, id); + m_loader = make_unique(m_dataSource, id); return *m_loader; } diff --git a/routing/bicycle_directions.hpp b/routing/bicycle_directions.hpp index 5fcb6df005..a95d79898e 100644 --- a/routing/bicycle_directions.hpp +++ b/routing/bicycle_directions.hpp @@ -28,7 +28,7 @@ public: using AdjacentEdgesMap = std::map; - BicycleDirectionsEngine(DataSourceBase const & index, std::shared_ptr numMwmIds); + BicycleDirectionsEngine(DataSourceBase const & dataSource, std::shared_ptr numMwmIds); // IDirectionsEngine override: bool Generate(IndexRoadGraph const & graph, vector const & path, @@ -56,7 +56,7 @@ private: AdjacentEdgesMap m_adjacentEdges; TUnpackedPathSegments m_pathSegments; - DataSourceBase const & m_index; + DataSourceBase const & m_dataSource; std::shared_ptr m_numMwmIds; std::unique_ptr m_loader; }; diff --git a/routing/cross_mwm_graph.cpp b/routing/cross_mwm_graph.cpp index 70051d025c..7351265c5e 100644 --- a/routing/cross_mwm_graph.cpp +++ b/routing/cross_mwm_graph.cpp @@ -50,14 +50,14 @@ CrossMwmGraph::CrossMwmGraph(shared_ptr numMwmIds, shared_ptr> numMwmTree, shared_ptr vehicleModelFactory, VehicleType vehicleType, CourntryRectFn const & countryRectFn, - DataSourceBase & index) - : m_index(index) + DataSourceBase & dataSource) + : m_dataSource(dataSource) , m_numMwmIds(numMwmIds) , m_numMwmTree(numMwmTree) , m_vehicleModelFactory(vehicleModelFactory) , m_countryRectFn(countryRectFn) - , m_crossMwmIndexGraph(index, numMwmIds, vehicleType) - , m_crossMwmTransitGraph(index, numMwmIds, VehicleType::Transit) + , m_crossMwmIndexGraph(dataSource, numMwmIds, vehicleType) + , m_crossMwmTransitGraph(dataSource, numMwmIds, VehicleType::Transit) { CHECK(m_numMwmIds, ()); CHECK(m_vehicleModelFactory, ()); @@ -200,7 +200,7 @@ void CrossMwmGraph::GetTwins(Segment const & s, bool isOutgoing, vector FindBestTwins(s.GetMwmId(), isOutgoing, ft, p, minDistSegs, twins); }; - m_index.ForEachInRect( + m_dataSource.ForEachInRect( findBestTwins, MercatorBounds::RectByCenterXYAndSizeInMeters(p, kTransitionEqualityDistM), scales::GetUpperScale()); @@ -258,7 +258,7 @@ TransitionPoints CrossMwmGraph::GetTransitionPoints(Segment const & s, bool isOu CrossMwmGraph::MwmStatus CrossMwmGraph::GetMwmStatus(NumMwmId numMwmId, string const & sectionName) const { - MwmSet::MwmHandle handle = m_index.GetMwmHandleByCountryFile(m_numMwmIds->GetFile(numMwmId)); + MwmSet::MwmHandle handle = m_dataSource.GetMwmHandleByCountryFile(m_numMwmIds->GetFile(numMwmId)); if (!handle.IsAlive()) return MwmStatus::NotLoaded; diff --git a/routing/cross_mwm_graph.hpp b/routing/cross_mwm_graph.hpp index 4735e13cd9..601ff16ad6 100644 --- a/routing/cross_mwm_graph.hpp +++ b/routing/cross_mwm_graph.hpp @@ -37,7 +37,7 @@ public: CrossMwmGraph(std::shared_ptr numMwmIds, shared_ptr> numMwmTree, std::shared_ptr vehicleModelFactory, VehicleType vehicleType, - CourntryRectFn const & countryRectFn, DataSourceBase & index); + CourntryRectFn const & countryRectFn, DataSourceBase & dataSource); /// \brief Transition segment is a segment which is crossed by mwm border. That means /// start and finish of such segment have to lie in different mwms. If a segment is @@ -148,7 +148,7 @@ private: void DeserializeTransitions(std::vector const & mwmIds); void DeserializeTransitTransitions(std::vector const & mwmIds); - DataSourceBase & m_index; + DataSourceBase & m_dataSource; std::shared_ptr m_numMwmIds; std::shared_ptr> m_numMwmTree; std::shared_ptr m_vehicleModelFactory; diff --git a/routing/cross_mwm_index_graph.hpp b/routing/cross_mwm_index_graph.hpp index c3faf1d7a6..eb69f9bb1d 100644 --- a/routing/cross_mwm_index_graph.hpp +++ b/routing/cross_mwm_index_graph.hpp @@ -66,8 +66,8 @@ class CrossMwmIndexGraph final public: using ReaderSourceFile = ReaderSource; - CrossMwmIndexGraph(DataSourceBase & index, std::shared_ptr numMwmIds, VehicleType vehicleType) - : m_index(index), m_numMwmIds(numMwmIds), m_vehicleType(vehicleType) + CrossMwmIndexGraph(DataSourceBase & dataSource, std::shared_ptr numMwmIds, VehicleType vehicleType) + : m_dataSource(dataSource), m_numMwmIds(numMwmIds), m_vehicleType(vehicleType) { } @@ -172,7 +172,7 @@ private: template CrossMwmConnector const & Deserialize(NumMwmId numMwmId, Fn && fn) { - MwmSet::MwmHandle handle = m_index.GetMwmHandleByCountryFile(m_numMwmIds->GetFile(numMwmId)); + MwmSet::MwmHandle handle = m_dataSource.GetMwmHandleByCountryFile(m_numMwmIds->GetFile(numMwmId)); if (!handle.IsAlive()) MYTHROW(RoutingException, ("Mwm", m_numMwmIds->GetFile(numMwmId), "cannot be loaded.")); @@ -193,7 +193,7 @@ private: return it->second; } - DataSourceBase & m_index; + DataSourceBase & m_dataSource; std::shared_ptr m_numMwmIds; VehicleType m_vehicleType; diff --git a/routing/features_road_graph.cpp b/routing/features_road_graph.cpp index 34b1040a3a..459b88d843 100644 --- a/routing/features_road_graph.cpp +++ b/routing/features_road_graph.cpp @@ -30,13 +30,13 @@ double constexpr kMwmCrossingNodeEqualityRadiusMeters = 100.0; double GetRoadCrossingRadiusMeters() { return kMwmRoadCrossingRadiusMeters; } -FeaturesRoadGraph::Value::Value(DataSourceBase const & index, MwmSet::MwmHandle handle) +FeaturesRoadGraph::Value::Value(DataSourceBase const & dataSource, MwmSet::MwmHandle handle) : m_mwmHandle(move(handle)) { if (!m_mwmHandle.IsAlive()) return; - m_altitudeLoader = make_unique(index, m_mwmHandle.GetId()); + m_altitudeLoader = make_unique(dataSource, m_mwmHandle.GetId()); } FeaturesRoadGraph::CrossCountryVehicleModel::CrossCountryVehicleModel( @@ -111,9 +111,9 @@ void FeaturesRoadGraph::RoadInfoCache::Clear() { m_cache.clear(); } -FeaturesRoadGraph::FeaturesRoadGraph(DataSourceBase const & index, IRoadGraph::Mode mode, +FeaturesRoadGraph::FeaturesRoadGraph(DataSourceBase const & dataSource, IRoadGraph::Mode mode, shared_ptr vehicleModelFactory) - : m_index(index), m_mode(mode), m_vehicleModel(vehicleModelFactory) + : m_dataSource(dataSource), m_mode(mode), m_vehicleModel(vehicleModelFactory) { } @@ -171,7 +171,7 @@ void FeaturesRoadGraph::ForEachFeatureClosestToCross(m2::PointD const & cross, { CrossFeaturesLoader featuresLoader(*this, edgesLoader); m2::RectD const rect = MercatorBounds::RectByCenterXYAndSizeInMeters(cross, kMwmRoadCrossingRadiusMeters); - m_index.ForEachInRect(featuresLoader, rect, GetStreetReadScale()); + m_dataSource.ForEachInRect(featuresLoader, rect, GetStreetReadScale()); } void FeaturesRoadGraph::FindClosestEdges(m2::PointD const & point, uint32_t count, @@ -195,7 +195,7 @@ void FeaturesRoadGraph::FindClosestEdges(m2::PointD const & point, uint32_t coun finder.AddInformationSource(featureId, roadInfo); }; - m_index.ForEachInRect( + m_dataSource.ForEachInRect( f, MercatorBounds::RectByCenterXYAndSizeInMeters(point, kMwmCrossingNodeEqualityRadiusMeters), GetStreetReadScale()); @@ -205,7 +205,7 @@ void FeaturesRoadGraph::FindClosestEdges(m2::PointD const & point, uint32_t coun void FeaturesRoadGraph::GetFeatureTypes(FeatureID const & featureId, feature::TypesHolder & types) const { FeatureType ft; - EditableDataSource::FeaturesLoaderGuard loader(m_index, featureId.m_mwmId); + EditableDataSource::FeaturesLoaderGuard loader(m_dataSource, featureId.m_mwmId); if (!loader.GetFeatureByIndex(featureId.m_index, ft)) return; @@ -236,7 +236,7 @@ void FeaturesRoadGraph::GetJunctionTypes(Junction const & junction, feature::Typ }; m2::RectD const rect = MercatorBounds::RectByCenterXYAndSizeInMeters(cross, kMwmRoadCrossingRadiusMeters); - m_index.ForEachInRect(f, rect, GetStreetReadScale()); + m_dataSource.ForEachInRect(f, rect, GetStreetReadScale()); } IRoadGraph::Mode FeaturesRoadGraph::GetMode() const @@ -306,7 +306,7 @@ IRoadGraph::RoadInfo const & FeaturesRoadGraph::GetCachedRoadInfo(FeatureID cons FeatureType ft; - EditableDataSource::FeaturesLoaderGuard loader(m_index, featureId.m_mwmId); + EditableDataSource::FeaturesLoaderGuard loader(m_dataSource, featureId.m_mwmId); if (!loader.GetFeatureByIndex(featureId.m_index, ft)) return ri; @@ -341,7 +341,7 @@ FeaturesRoadGraph::Value const & FeaturesRoadGraph::LockMwm(MwmSet::MwmId const if (itr != m_mwmLocks.end()) return itr->second; - return m_mwmLocks.insert(make_pair(move(mwmId), Value(m_index, m_index.GetMwmHandleById(mwmId)))) + return m_mwmLocks.insert(make_pair(move(mwmId), Value(m_dataSource, m_dataSource.GetMwmHandleById(mwmId)))) .first->second; } } // namespace routing diff --git a/routing/features_road_graph.hpp b/routing/features_road_graph.hpp index c2e559d481..59bcc98567 100644 --- a/routing/features_road_graph.hpp +++ b/routing/features_road_graph.hpp @@ -63,7 +63,7 @@ private: }; public: - FeaturesRoadGraph(DataSourceBase const & index, IRoadGraph::Mode mode, + FeaturesRoadGraph(DataSourceBase const & dataSource, IRoadGraph::Mode mode, shared_ptr vehicleModelFactory); static int GetStreetReadScale(); @@ -89,7 +89,7 @@ private: struct Value { Value() = default; - Value(DataSourceBase const & index, MwmSet::MwmHandle handle); + Value(DataSourceBase const & dataSource, MwmSet::MwmHandle handle); bool IsAlive() const { return m_mwmHandle.IsAlive(); } @@ -112,7 +112,7 @@ private: Value const & LockMwm(MwmSet::MwmId const & mwmId) const; - DataSourceBase const & m_index; + DataSourceBase const & m_dataSource; IRoadGraph::Mode const m_mode; mutable RoadInfoCache m_cache; mutable CrossCountryVehicleModel m_vehicleModel; diff --git a/routing/geometry.cpp b/routing/geometry.cpp index 03709186f3..6b78be91b1 100644 --- a/routing/geometry.cpp +++ b/routing/geometry.cpp @@ -25,7 +25,7 @@ size_t constexpr kRoadsCacheSize = 5000; class GeometryLoaderImpl final : public GeometryLoader { public: - GeometryLoaderImpl(DataSourceBase const & index, MwmSet::MwmHandle const & handle, + GeometryLoaderImpl(DataSourceBase const & dataSource, MwmSet::MwmHandle const & handle, shared_ptr vehicleModel, bool loadAltitudes); // GeometryLoader overrides: @@ -39,12 +39,12 @@ private: bool const m_loadAltitudes; }; -GeometryLoaderImpl::GeometryLoaderImpl(DataSourceBase const & index, MwmSet::MwmHandle const & handle, +GeometryLoaderImpl::GeometryLoaderImpl(DataSourceBase const & dataSource, MwmSet::MwmHandle const & handle, shared_ptr vehicleModel, bool loadAltitudes) : m_vehicleModel(move(vehicleModel)) - , m_guard(index, handle.GetId()) + , m_guard(dataSource, handle.GetId()) , m_country(handle.GetInfo()->GetCountryName()) - , m_altitudeLoader(index, handle.GetId()) + , m_altitudeLoader(dataSource, handle.GetId()) , m_loadAltitudes(loadAltitudes) { CHECK(handle.IsAlive(), ()); @@ -161,13 +161,13 @@ RoadGeometry const & Geometry::GetRoad(uint32_t featureId) } // static -unique_ptr GeometryLoader::Create(DataSourceBase const & index, +unique_ptr GeometryLoader::Create(DataSourceBase const & dataSource, MwmSet::MwmHandle const & handle, shared_ptr vehicleModel, bool loadAltitudes) { CHECK(handle.IsAlive(), ()); - return make_unique(index, handle, vehicleModel, loadAltitudes); + return make_unique(dataSource, handle, vehicleModel, loadAltitudes); } // static diff --git a/routing/geometry.hpp b/routing/geometry.hpp index cdbb9d157e..5ea0b2cfa8 100644 --- a/routing/geometry.hpp +++ b/routing/geometry.hpp @@ -79,7 +79,7 @@ public: virtual void Load(uint32_t featureId, RoadGeometry & road) = 0; // handle should be alive: it is caller responsibility to check it. - static std::unique_ptr Create(DataSourceBase const & index, + static std::unique_ptr Create(DataSourceBase const & dataSource, MwmSet::MwmHandle const & handle, std::shared_ptr vehicleModel, bool loadAltitudes); diff --git a/routing/index_graph_loader.cpp b/routing/index_graph_loader.cpp index b1218e1aba..e0221fd623 100644 --- a/routing/index_graph_loader.cpp +++ b/routing/index_graph_loader.cpp @@ -22,7 +22,7 @@ class IndexGraphLoaderImpl final : public IndexGraphLoader public: IndexGraphLoaderImpl(VehicleType vehicleType, bool loadAltitudes, shared_ptr numMwmIds, shared_ptr vehicleModelFactory, - shared_ptr estimator, DataSourceBase & index); + shared_ptr estimator, DataSourceBase & dataSource); // IndexGraphLoader overrides: Geometry & GetGeometry(NumMwmId numMwmId) override; @@ -41,7 +41,7 @@ private: VehicleType m_vehicleType; bool m_loadAltitudes; - DataSourceBase & m_index; + DataSourceBase & m_dataSource; shared_ptr m_numMwmIds; shared_ptr m_vehicleModelFactory; shared_ptr m_estimator; @@ -51,10 +51,10 @@ private: IndexGraphLoaderImpl::IndexGraphLoaderImpl( VehicleType vehicleType, bool loadAltitudes, shared_ptr numMwmIds, shared_ptr vehicleModelFactory, - shared_ptr estimator, DataSourceBase & index) + shared_ptr estimator, DataSourceBase & dataSource) : m_vehicleType(vehicleType) , m_loadAltitudes(loadAltitudes) - , m_index(index) + , m_dataSource(dataSource) , m_numMwmIds(numMwmIds) , m_vehicleModelFactory(vehicleModelFactory) , m_estimator(estimator) @@ -88,7 +88,7 @@ IndexGraph & IndexGraphLoaderImpl::GetIndexGraph(NumMwmId numMwmId) IndexGraphLoaderImpl::GeometryIndexGraph & IndexGraphLoaderImpl::CreateGeometry(NumMwmId numMwmId) { platform::CountryFile const & file = m_numMwmIds->GetFile(numMwmId); - MwmSet::MwmHandle handle = m_index.GetMwmHandleByCountryFile(file); + MwmSet::MwmHandle handle = m_dataSource.GetMwmHandleByCountryFile(file); if (!handle.IsAlive()) MYTHROW(RoutingException, ("Can't get mwm handle for", file)); @@ -97,7 +97,7 @@ IndexGraphLoaderImpl::GeometryIndexGraph & IndexGraphLoaderImpl::CreateGeometry( auto & graph = m_graphs[numMwmId]; graph.m_geometry = - make_shared(GeometryLoader::Create(m_index, handle, vehicleModel, m_loadAltitudes)); + make_shared(GeometryLoader::Create(m_dataSource, handle, vehicleModel, m_loadAltitudes)); return graph; } @@ -106,7 +106,7 @@ IndexGraphLoaderImpl::GeometryIndexGraph & IndexGraphLoaderImpl::CreateIndexGrap { CHECK(graph.m_geometry, ()); platform::CountryFile const & file = m_numMwmIds->GetFile(numMwmId); - MwmSet::MwmHandle handle = m_index.GetMwmHandleByCountryFile(file); + MwmSet::MwmHandle handle = m_dataSource.GetMwmHandleByCountryFile(file); if (!handle.IsAlive()) MYTHROW(RoutingException, ("Can't get mwm handle for", file)); @@ -149,10 +149,10 @@ namespace routing unique_ptr IndexGraphLoader::Create( VehicleType vehicleType, bool loadAltitudes, shared_ptr numMwmIds, shared_ptr vehicleModelFactory, shared_ptr estimator, - DataSourceBase & index) + DataSourceBase & dataSource) { return make_unique(vehicleType, loadAltitudes, numMwmIds, vehicleModelFactory, - estimator, index); + estimator, dataSource); } void DeserializeIndexGraph(MwmValue const & mwmValue, VehicleType vehicleType, IndexGraph & graph) diff --git a/routing/index_graph_loader.hpp b/routing/index_graph_loader.hpp index bcb8336d81..e46b64f33a 100644 --- a/routing/index_graph_loader.hpp +++ b/routing/index_graph_loader.hpp @@ -26,7 +26,7 @@ public: static std::unique_ptr Create( VehicleType vehicleType, bool loadAltitudes, std::shared_ptr numMwmIds, std::shared_ptr vehicleModelFactory, - std::shared_ptr estimator, DataSourceBase & index); + std::shared_ptr estimator, DataSourceBase & dataSource); }; void DeserializeIndexGraph(MwmValue const & mwmValue, VehicleType vehicleType, IndexGraph & graph); diff --git a/routing/index_road_graph.cpp b/routing/index_road_graph.cpp index e8e81d863c..5d50fd2f38 100644 --- a/routing/index_road_graph.cpp +++ b/routing/index_road_graph.cpp @@ -13,8 +13,8 @@ namespace routing { IndexRoadGraph::IndexRoadGraph(shared_ptr numMwmIds, IndexGraphStarter & starter, vector const & segments, vector const & junctions, - DataSourceBase & index) - : m_index(index), m_numMwmIds(numMwmIds), m_starter(starter), m_segments(segments) + DataSourceBase & dataSource) + : m_dataSource(dataSource), m_numMwmIds(numMwmIds), m_starter(starter), m_segments(segments) { // j0 j1 j2 j3 // *--s0--*--s1--*--s2--* @@ -60,7 +60,7 @@ void IndexRoadGraph::GetEdgeTypes(Edge const & edge, feature::TypesHolder & type FeatureID const featureId = edge.GetFeatureId(); FeatureType ft; - EditableDataSource::FeaturesLoaderGuard loader(m_index, featureId.m_mwmId); + EditableDataSource::FeaturesLoaderGuard loader(m_dataSource, featureId.m_mwmId); if (!loader.GetFeatureByIndex(featureId.m_index, ft)) { LOG(LERROR, ("Can't load types for feature", featureId)); @@ -92,7 +92,7 @@ void IndexRoadGraph::GetRouteEdges(TEdgeVector & edges) const if (m_starter.ConvertToReal(real)) { platform::CountryFile const & file = m_numMwmIds->GetFile(real.GetMwmId()); - MwmSet::MwmId const mwmId = m_index.GetMwmIdByCountryFile(file); + MwmSet::MwmId const mwmId = m_dataSource.GetMwmIdByCountryFile(file); edges.push_back(Edge::MakeFakeWithRealPart(FeatureID(mwmId, real.GetFeatureId()), real.IsForward(), real.GetSegmentIdx(), junctionFrom, junctionTo)); @@ -105,7 +105,7 @@ void IndexRoadGraph::GetRouteEdges(TEdgeVector & edges) const else { platform::CountryFile const & file = m_numMwmIds->GetFile(segment.GetMwmId()); - MwmSet::MwmId const mwmId = m_index.GetMwmIdByCountryFile(file); + MwmSet::MwmId const mwmId = m_dataSource.GetMwmIdByCountryFile(file); edges.push_back(Edge::MakeReal(FeatureID(mwmId, segment.GetFeatureId()), segment.IsForward(), segment.GetSegmentIdx(), junctionFrom, junctionTo)); } @@ -137,7 +137,7 @@ void IndexRoadGraph::GetEdges(Junction const & junction, bool isOutgoing, TEdgeV continue; platform::CountryFile const & file = m_numMwmIds->GetFile(segment.GetMwmId()); - MwmSet::MwmId const mwmId = m_index.GetMwmIdByCountryFile(file); + MwmSet::MwmId const mwmId = m_dataSource.GetMwmIdByCountryFile(file); edges.push_back(Edge::MakeReal(FeatureID(mwmId, segment.GetFeatureId()), segment.IsForward(), segment.GetSegmentIdx(), diff --git a/routing/index_road_graph.hpp b/routing/index_road_graph.hpp index 804b2ac68a..43e8f6d881 100644 --- a/routing/index_road_graph.hpp +++ b/routing/index_road_graph.hpp @@ -19,7 +19,7 @@ class IndexRoadGraph : public RoadGraphBase public: IndexRoadGraph(std::shared_ptr numMwmIds, IndexGraphStarter & starter, std::vector const & segments, std::vector const & junctions, - DataSourceBase & index); + DataSourceBase & dataSource); // IRoadGraphBase overrides: virtual void GetOutgoingEdges(Junction const & junction, TEdgeVector & edges) const override; @@ -35,7 +35,7 @@ private: void GetEdges(Junction const & junction, bool isOutgoing, TEdgeVector & edges) const; std::vector const & GetSegments(Junction const & junction, bool isOutgoing) const; - DataSourceBase & m_index; + DataSourceBase & m_dataSource; std::shared_ptr m_numMwmIds; IndexGraphStarter & m_starter; std::vector m_segments; diff --git a/routing/index_router.cpp b/routing/index_router.cpp index 1f0aa06d65..472767b771 100644 --- a/routing/index_router.cpp +++ b/routing/index_router.cpp @@ -101,7 +101,7 @@ shared_ptr CreateVehicleModelFactory( } unique_ptr CreateDirectionsEngine(VehicleType vehicleType, - shared_ptr numMwmIds, DataSourceBase & index) + shared_ptr numMwmIds, DataSourceBase & dataSource) { switch (vehicleType) { @@ -110,7 +110,7 @@ unique_ptr CreateDirectionsEngine(VehicleType vehicleType, case VehicleType::Bicycle: // @TODO Bicycle turn generation engine is used now. It's ok for the time being. // But later a special car turn generation engine should be implemented. - case VehicleType::Car: return make_unique(index, numMwmIds); + case VehicleType::Car: return make_unique(dataSource, numMwmIds); case VehicleType::Count: CHECK(false, ("Can't create DirectionsEngine for", vehicleType)); return nullptr; @@ -154,11 +154,11 @@ bool MwmHasRoutingData(version::MwmTraits const & traits) return traits.HasRoutingIndex() && traits.HasCrossMwmSection(); } -void GetOutdatedMwms(DataSourceBase & index, vector & outdatedMwms) +void GetOutdatedMwms(DataSourceBase & dataSource, vector & outdatedMwms) { outdatedMwms.clear(); vector> infos; - index.GetMwmsInfo(infos); + dataSource.GetMwmsInfo(infos); for (auto const & info : infos) { @@ -274,18 +274,18 @@ IndexRouter::IndexRouter(VehicleType vehicleType, bool loadAltitudes, CountryParentNameGetterFn const & countryParentNameGetterFn, TCountryFileFn const & countryFileFn, CourntryRectFn const & countryRectFn, shared_ptr numMwmIds, unique_ptr> numMwmTree, - traffic::TrafficCache const & trafficCache, DataSourceBase & index) + traffic::TrafficCache const & trafficCache, DataSourceBase & dataSource) : m_vehicleType(vehicleType) , m_loadAltitudes(loadAltitudes) , m_name("astar-bidirectional-" + ToString(m_vehicleType)) - , m_index(index) + , m_dataSource(dataSource) , m_vehicleModelFactory(CreateVehicleModelFactory(m_vehicleType, countryParentNameGetterFn)) , m_countryFileFn(countryFileFn) , m_countryRectFn(countryRectFn) , m_numMwmIds(move(numMwmIds)) , m_numMwmTree(move(numMwmTree)) , m_trafficStash(CreateTrafficStash(m_vehicleType, m_numMwmIds, trafficCache)) - , m_roadGraph(m_index, + , m_roadGraph(m_dataSource, vehicleType == VehicleType::Pedestrian || vehicleType == VehicleType::Transit ? IRoadGraph::Mode::IgnoreOnewayTag : IRoadGraph::Mode::ObeyOnewayTag, @@ -293,7 +293,7 @@ IndexRouter::IndexRouter(VehicleType vehicleType, bool loadAltitudes, , m_estimator(EdgeEstimator::Create( m_vehicleType, CalcMaxSpeed(*m_numMwmIds, *m_vehicleModelFactory, m_vehicleType), CalcOffroadSpeed(*m_vehicleModelFactory), m_trafficStash)) - , m_directionsEngine(CreateDirectionsEngine(m_vehicleType, m_numMwmIds, m_index)) + , m_directionsEngine(CreateDirectionsEngine(m_vehicleType, m_numMwmIds, m_dataSource)) { CHECK(!m_name.empty(), ()); CHECK(m_numMwmIds, ()); @@ -325,7 +325,7 @@ RouterResultCode IndexRouter::CalculateRoute(Checkpoints const & checkpoints, RouterDelegate const & delegate, Route & route) { vector outdatedMwms; - GetOutdatedMwms(m_index, outdatedMwms); + GetOutdatedMwms(m_dataSource, outdatedMwms); if (!outdatedMwms.empty()) { @@ -385,7 +385,7 @@ RouterResultCode IndexRouter::DoCalculateRoute(Checkpoints const & checkpoints, } auto const country = platform::CountryFile(countryName); - if (!m_index.IsLoaded(country)) + if (!m_dataSource.IsLoaded(country)) route.AddAbsentCountry(country.GetName()); } @@ -664,16 +664,16 @@ unique_ptr IndexRouter::MakeWorldGraph() auto crossMwmGraph = make_unique( m_numMwmIds, m_numMwmTree, m_vehicleModelFactory, m_vehicleType == VehicleType::Transit ? VehicleType::Pedestrian : m_vehicleType, - m_countryRectFn, m_index); + m_countryRectFn, m_dataSource); auto indexGraphLoader = IndexGraphLoader::Create( m_vehicleType == VehicleType::Transit ? VehicleType::Pedestrian : m_vehicleType, - m_loadAltitudes, m_numMwmIds, m_vehicleModelFactory, m_estimator, m_index); + m_loadAltitudes, m_numMwmIds, m_vehicleModelFactory, m_estimator, m_dataSource); if (m_vehicleType != VehicleType::Transit) { return make_unique(move(crossMwmGraph), move(indexGraphLoader), m_estimator); } - auto transitGraphLoader = TransitGraphLoader::Create(m_index, m_numMwmIds, m_estimator); + auto transitGraphLoader = TransitGraphLoader::Create(m_dataSource, m_numMwmIds, m_estimator); return make_unique(move(crossMwmGraph), move(indexGraphLoader), move(transitGraphLoader), m_estimator); } @@ -683,7 +683,7 @@ bool IndexRouter::FindBestSegment(m2::PointD const & point, m2::PointD const & d bool & bestSegmentIsAlmostCodirectional) const { auto const file = platform::CountryFile(m_countryFileFn(point)); - MwmSet::MwmHandle handle = m_index.GetMwmHandleByCountryFile(file); + MwmSet::MwmHandle handle = m_dataSource.GetMwmHandleByCountryFile(file); if (!handle.IsAlive()) MYTHROW(MwmIsNotAliveException, ("Can't get mwm handle for", file)); @@ -853,7 +853,7 @@ RouterResultCode IndexRouter::RedressRoute(vector const & segments, for (size_t i = 0; i < numPoints; ++i) junctions.emplace_back(starter.GetRouteJunction(segments, i)); - IndexRoadGraph roadGraph(m_numMwmIds, starter, segments, junctions, m_index); + IndexRoadGraph roadGraph(m_numMwmIds, starter, segments, junctions, m_dataSource); starter.GetGraph().SetMode(WorldGraph::Mode::NoLeaps); Route::TTimes times; @@ -905,7 +905,7 @@ bool IndexRouter::DoesTransitSectionExist(NumMwmId numMwmId) const CHECK(m_numMwmIds, ()); platform::CountryFile const & file = m_numMwmIds->GetFile(numMwmId); - MwmSet::MwmHandle handle = m_index.GetMwmHandleByCountryFile(file); + MwmSet::MwmHandle handle = m_dataSource.GetMwmHandleByCountryFile(file); if (!handle.IsAlive()) MYTHROW(RoutingException, ("Can't get mwm handle for", file)); diff --git a/routing/index_router.hpp b/routing/index_router.hpp index 4b7ec5b7b6..41d7b04013 100644 --- a/routing/index_router.hpp +++ b/routing/index_router.hpp @@ -65,7 +65,7 @@ public: IndexRouter(VehicleType vehicleType, bool loadAltitudes, CountryParentNameGetterFn const & countryParentNameGetterFn, TCountryFileFn const & countryFileFn, CourntryRectFn const & countryRectFn, shared_ptr numMwmIds, unique_ptr> numMwmTree, - traffic::TrafficCache const & trafficCache, DataSourceBase & index); + traffic::TrafficCache const & trafficCache, DataSourceBase & dataSource); std::unique_ptr MakeSingleMwmWorldGraph(); bool FindBestSegment(m2::PointD const & point, m2::PointD const & direction, @@ -147,7 +147,7 @@ private: VehicleType m_vehicleType; bool m_loadAltitudes; std::string const m_name; - DataSourceBase & m_index; + DataSourceBase & m_dataSource; std::shared_ptr m_vehicleModelFactory; TCountryFileFn const m_countryFileFn; diff --git a/routing/routing_benchmarks/bicycle_routing_tests.cpp b/routing/routing_benchmarks/bicycle_routing_tests.cpp index f7d09bac20..5b3e1d66b8 100644 --- a/routing/routing_benchmarks/bicycle_routing_tests.cpp +++ b/routing/routing_benchmarks/bicycle_routing_tests.cpp @@ -29,7 +29,7 @@ protected: shared_ptr numMwmIds) override { unique_ptr engine(new routing::BicycleDirectionsEngine( - m_index, numMwmIds)); + m_dataSource, numMwmIds)); return engine; } diff --git a/routing/routing_benchmarks/helpers.cpp b/routing/routing_benchmarks/helpers.cpp index 48b726790d..abddbcd2b3 100644 --- a/routing/routing_benchmarks/helpers.cpp +++ b/routing/routing_benchmarks/helpers.cpp @@ -81,11 +81,11 @@ RoutingTest::RoutingTest(routing::IRoadGraph::Mode mode, set const & nee if (m_neededMaps.count(name) == 0) continue; - UNUSED_VALUE(m_index.RegisterMap(localFile)); + UNUSED_VALUE(m_dataSource.RegisterMap(localFile)); auto const & countryFile = localFile.GetCountryFile(); - TEST(m_index.IsLoaded(countryFile), ()); - MwmSet::MwmId const id = m_index.GetMwmIdByCountryFile(countryFile); + TEST(m_dataSource.IsLoaded(countryFile), ()); + MwmSet::MwmId const id = m_dataSource.GetMwmIdByCountryFile(countryFile); TEST(id.IsAlive(), ()); registeredMaps.insert(name); @@ -153,13 +153,13 @@ unique_ptr RoutingTest::CreateRouter(string const & name) } unique_ptr router = integration::CreateVehicleRouter( - m_index, *m_cig, m_trafficCache, neededLocalFiles, routing::VehicleType::Pedestrian); + m_dataSource, *m_cig, m_trafficCache, neededLocalFiles, routing::VehicleType::Pedestrian); return router; } void RoutingTest::GetNearestEdges(m2::PointD const & pt, vector> & edges) { - routing::FeaturesRoadGraph graph(m_index, m_mode, CreateModelFactory()); + routing::FeaturesRoadGraph graph(m_dataSource, m_mode, CreateModelFactory()); graph.FindClosestEdges(pt, 1 /* count */, edges); } diff --git a/routing/routing_benchmarks/helpers.hpp b/routing/routing_benchmarks/helpers.hpp index 1d6d948140..31f0444a73 100644 --- a/routing/routing_benchmarks/helpers.hpp +++ b/routing/routing_benchmarks/helpers.hpp @@ -42,7 +42,7 @@ protected: std::vector> & edges); routing::IRoadGraph::Mode const m_mode; - DataSource m_index; + DataSource m_dataSource; traffic::TrafficCache m_trafficCache; std::vector m_localFiles; diff --git a/routing/routing_integration_tests/get_altitude_test.cpp b/routing/routing_integration_tests/get_altitude_test.cpp index 525f08fcfc..bb561eea76 100644 --- a/routing/routing_integration_tests/get_altitude_test.cpp +++ b/routing/routing_integration_tests/get_altitude_test.cpp @@ -43,18 +43,18 @@ LocalCountryFile GetLocalCountryFileByCountryId(CountryFile const & country) void TestAltitudeOfAllMwmFeatures(string const & countryId, TAltitude const altitudeLowerBoundMeters, TAltitude const altitudeUpperBoundMeters) { - DataSource index; + DataSource dataSource; LocalCountryFile const country = GetLocalCountryFileByCountryId(CountryFile(countryId)); TEST_NOT_EQUAL(country, LocalCountryFile(), ()); TEST_NOT_EQUAL(country.GetFiles(), MapOptions::Nothing, (country)); - pair const regResult = index.RegisterMap(country); + pair const regResult = dataSource.RegisterMap(country); TEST_EQUAL(regResult.second, MwmSet::RegResult::Success, ()); TEST(regResult.first.IsAlive(), ()); unique_ptr altitudeLoader = - make_unique(index, regResult.first /* mwmId */); + make_unique(dataSource, regResult.first /* mwmId */); classificator::Load(); classif().SortClassificator(); diff --git a/routing/routing_integration_tests/road_graph_tests.cpp b/routing/routing_integration_tests/road_graph_tests.cpp index c2e990c361..ebac0badeb 100644 --- a/routing/routing_integration_tests/road_graph_tests.cpp +++ b/routing/routing_integration_tests/road_graph_tests.cpp @@ -31,14 +31,14 @@ UNIT_TEST(FakeEdgesCombinatorialExplosion) GetAllLocalFiles(localFiles); TEST(!localFiles.empty(), ()); - DataSource index; + DataSource dataSource; for (auto const & file : localFiles) { - auto const result = index.Register(file); + auto const result = dataSource.Register(file); TEST_EQUAL(result.second, MwmSet::RegResult::Success, ()); } - FeaturesRoadGraph graph(index, IRoadGraph::Mode::ObeyOnewayTag, + FeaturesRoadGraph graph(dataSource, IRoadGraph::Mode::ObeyOnewayTag, make_shared(CountryParentNameGetterFn())); Junction const j(m2::PointD(MercatorBounds::FromLatLon(50.73208, -1.21279)), feature::kDefaultAltitudeMeters); std::vector> sourceVicinity; diff --git a/routing/routing_integration_tests/routing_test_tools.cpp b/routing/routing_integration_tests/routing_test_tools.cpp index 46931f03ff..8a4275689c 100644 --- a/routing/routing_integration_tests/routing_test_tools.cpp +++ b/routing/routing_integration_tests/routing_test_tools.cpp @@ -41,7 +41,7 @@ using namespace routing; using namespace routing_test; using TRouterFactory = - function(DataSourceBase & index, TCountryFileFn const & countryFileFn, + function(DataSourceBase & dataSource, TCountryFileFn const & countryFileFn, shared_ptr numMwmIds)>; namespace @@ -85,7 +85,7 @@ namespace integration return storage::CountryInfoReader::CreateCountryInfoReader(platform); } - unique_ptr CreateVehicleRouter(DataSourceBase & index, + unique_ptr CreateVehicleRouter(DataSourceBase & dataSource, storage::CountryInfoGetter const & infoGetter, traffic::TrafficCache const & trafficCache, vector const & localFiles, @@ -103,7 +103,7 @@ namespace integration for (auto const & f : localFiles) { auto const & countryFile = f.GetCountryFile(); - auto const mwmId = index.GetMwmIdByCountryFile(countryFile); + auto const mwmId = dataSource.GetMwmIdByCountryFile(countryFile); CHECK(mwmId.IsAlive(), ()); if (mwmId.GetInfo()->GetType() == MwmInfo::COUNTRY && countryFile.GetName() != "minsk-pass") numMwmIds->RegisterFile(countryFile); @@ -115,12 +115,12 @@ namespace integration auto indexRouter = make_unique(vehicleType, false /* load altitudes*/, *countryParentGetter, countryFileGetter, getMwmRectByName, numMwmIds, - MakeNumMwmTree(*numMwmIds, infoGetter), trafficCache, index); + MakeNumMwmTree(*numMwmIds, infoGetter), trafficCache, dataSource); return indexRouter; } - unique_ptr CreateAStarRouter(DataSourceBase & index, + unique_ptr CreateAStarRouter(DataSourceBase & dataSource, storage::CountryInfoGetter const & infoGetter, vector const & localFiles, TRouterFactory const & routerFactory) @@ -136,7 +136,7 @@ namespace integration for (auto const & file : localFiles) numMwmIds->RegisterFile(file.GetCountryFile()); - unique_ptr router = routerFactory(index, countryFileGetter, numMwmIds); + unique_ptr router = routerFactory(dataSource, countryFileGetter, numMwmIds); return unique_ptr(move(router)); } diff --git a/routing/routing_integration_tests/routing_test_tools.hpp b/routing/routing_integration_tests/routing_test_tools.hpp index 6c659f7da9..88da715494 100644 --- a/routing/routing_integration_tests/routing_test_tools.hpp +++ b/routing/routing_integration_tests/routing_test_tools.hpp @@ -51,7 +51,7 @@ shared_ptr CreateFeaturesFetcher(vector CreateCountryInfoGetter(); -unique_ptr CreateVehicleRouter(DataSourceBase & index, +unique_ptr CreateVehicleRouter(DataSourceBase & dataSource, storage::CountryInfoGetter const & infoGetter, traffic::TrafficCache const & trafficCache, vector const & localFiles, @@ -81,7 +81,7 @@ class VehicleRouterComponents : public IRouterComponents public: VehicleRouterComponents(vector const & localFiles, VehicleType vehicleType) : IRouterComponents(localFiles) - , m_indexRouter(CreateVehicleRouter(m_featuresFetcher->GetIndex(), *m_infoGetter, m_trafficCache, + , m_indexRouter(CreateVehicleRouter(m_featuresFetcher->GetDataSource(), *m_infoGetter, m_trafficCache, localFiles, vehicleType)) { } diff --git a/routing/routing_session.cpp b/routing/routing_session.cpp index fcd91502a3..e8a26acd98 100644 --- a/routing/routing_session.cpp +++ b/routing/routing_session.cpp @@ -285,7 +285,7 @@ void RoutingSession::ResetImpl() } RoutingSession::State RoutingSession::OnLocationPositionChanged(GpsInfo const & info, - DataSourceBase const & index) + DataSourceBase const & dataSource) { threads::MutexGuard guard(m_routingSessionMutex); ASSERT(m_state != RoutingNotActive, ()); @@ -328,7 +328,7 @@ RoutingSession::State RoutingSession::OnLocationPositionChanged(GpsInfo const & double const warningDistanceM = max(kSpeedCameraMinimalWarningMeters, info.m_speed * kSpeedCameraWarningSeconds); SpeedCameraRestriction cam(0, 0); - double const camDistance = GetDistanceToCurrentCamM(cam, index); + double const camDistance = GetDistanceToCurrentCamM(cam, dataSource); if (kInvalidSpeedCameraDistance != camDistance && camDistance < warningDistanceM) { if (cam.m_index > m_lastWarnedSpeedCameraIndex && info.m_speed > cam.m_maxSpeedKmH * kKmHToMps) @@ -663,7 +663,7 @@ string RoutingSession::GetTurnNotificationsLocale() const return m_turnNotificationsMgr.GetLocale(); } -double RoutingSession::GetDistanceToCurrentCamM(SpeedCameraRestriction & camera, DataSourceBase const & index) +double RoutingSession::GetDistanceToCurrentCamM(SpeedCameraRestriction & camera, DataSourceBase const & dataSource) { ASSERT(m_route, ()); @@ -679,7 +679,7 @@ double RoutingSession::GetDistanceToCurrentCamM(SpeedCameraRestriction & camera, size_t const upperBound = min(m_poly.GetPolyline().GetSize(), currentIndex + kSpeedCameraLookAheadCount); for (m_lastCheckedSpeedCameraIndex = currentIndex; m_lastCheckedSpeedCameraIndex < upperBound; ++m_lastCheckedSpeedCameraIndex) { - uint8_t speed = CheckCameraInPoint(m_poly.GetPolyline().GetPoint(m_lastCheckedSpeedCameraIndex), index); + uint8_t speed = CheckCameraInPoint(m_poly.GetPolyline().GetPoint(m_lastCheckedSpeedCameraIndex), dataSource); if (speed != kNoSpeedCamera) { camera = SpeedCameraRestriction(static_cast(m_lastCheckedSpeedCameraIndex), speed); diff --git a/routing/routing_session.hpp b/routing/routing_session.hpp index 07b3391a9a..505576166e 100644 --- a/routing/routing_session.hpp +++ b/routing/routing_session.hpp @@ -120,7 +120,7 @@ public: bool GetRouteAltitudesAndDistancesM(vector & routeSegDistanceM, feature::TAltitudes & routeAltitudesM) const; - State OnLocationPositionChanged(location::GpsInfo const & info, DataSourceBase const & index); + State OnLocationPositionChanged(location::GpsInfo const & info, DataSourceBase const & dataSource); void GetRouteFollowingInfo(location::FollowingInfo & info) const; void MatchLocationToRoute(location::GpsInfo & location, @@ -191,7 +191,7 @@ private: /// Returns a nearest speed camera record on your way and distance to it. /// Returns kInvalidSpeedCameraDistance if there is no cameras on your way. // Should be called with locked m_routingSessionMutex. - double GetDistanceToCurrentCamM(SpeedCameraRestriction & camera, DataSourceBase const & index); + double GetDistanceToCurrentCamM(SpeedCameraRestriction & camera, DataSourceBase const & dataSource); /// RemoveRoute removes m_route and resets route attributes (m_state, m_lastDistance, m_moveAwayCounter). void RemoveRoute(); diff --git a/routing/routing_tests/routing_session_test.cpp b/routing/routing_tests/routing_session_test.cpp index 72533be249..bdd5761b91 100644 --- a/routing/routing_tests/routing_session_test.cpp +++ b/routing/routing_tests/routing_session_test.cpp @@ -114,7 +114,7 @@ UNIT_TEST(TestRouteBuilding) UNIT_TEST(TestRouteRebuilding) { - DataSource index; + DataSource dataSource; RoutingSession session; session.Init(nullptr, nullptr); vector routePoints = kTestRoute; @@ -144,7 +144,7 @@ UNIT_TEST(TestRouteRebuilding) RoutingSession::State code; while (info.m_latitude < kTestRoute.back().y) { - code = session.OnLocationPositionChanged(info, index); + code = session.OnLocationPositionChanged(info, dataSource); TEST_EQUAL(code, RoutingSession::State::OnRoute, ()); info.m_latitude += 0.01; } @@ -164,7 +164,7 @@ UNIT_TEST(TestRouteRebuilding) info.m_latitude = 1.; for (size_t i = 0; i < 10; ++i) { - code = session.OnLocationPositionChanged(info, index); + code = session.OnLocationPositionChanged(info, dataSource); info.m_latitude -= 0.1; } TEST_EQUAL(code, RoutingSession::State::RouteNeedRebuild, ()); @@ -172,7 +172,7 @@ UNIT_TEST(TestRouteRebuilding) UNIT_TEST(TestFollowRouteFlagPersistence) { - DataSource index; + DataSource dataSource; RoutingSession session; session.Init(nullptr, nullptr); vector routePoints = kTestRoute; @@ -206,7 +206,7 @@ UNIT_TEST(TestFollowRouteFlagPersistence) RoutingSession::State code; while (info.m_latitude < kTestRoute.back().y) { - session.OnLocationPositionChanged(info, index); + session.OnLocationPositionChanged(info, dataSource); TEST(session.IsOnRoute() , ()); TEST(session.IsFollowing(), ()); info.m_latitude += 0.01; @@ -231,7 +231,7 @@ UNIT_TEST(TestFollowRouteFlagPersistence) info.m_latitude = 1.; for (size_t i = 0; i < 10; ++i) { - code = session.OnLocationPositionChanged(info, index); + code = session.OnLocationPositionChanged(info, dataSource); info.m_latitude -= 0.1; } TEST_EQUAL(code, RoutingSession::State::RouteNeedRebuild, ()); @@ -248,7 +248,7 @@ UNIT_TEST(TestFollowRouteFlagPersistence) UNIT_TEST(TestFollowRoutePercentTest) { - DataSource index; + DataSource dataSource; RoutingSession session; session.Init(nullptr, nullptr); vector routePoints = kTestRoute; @@ -282,23 +282,23 @@ UNIT_TEST(TestFollowRoutePercentTest) // Go through the route. info.m_longitude = 0.; info.m_latitude = 1.; - session.OnLocationPositionChanged(info, index); + session.OnLocationPositionChanged(info, dataSource); TEST(my::AlmostEqualAbs(session.GetCompletionPercent(), 0., 0.5), ()); info.m_longitude = 0.; info.m_latitude = 2.; - session.OnLocationPositionChanged(info, index); + session.OnLocationPositionChanged(info, dataSource); TEST(my::AlmostEqualAbs(session.GetCompletionPercent(), 33.3, 0.5), ()); info.m_longitude = 0.; info.m_latitude = 3.; - session.OnLocationPositionChanged(info, index); + session.OnLocationPositionChanged(info, dataSource); TEST(my::AlmostEqualAbs(session.GetCompletionPercent(), 66.6, 0.5), ()); info.m_longitude = 0.; info.m_latitude = 3.99; - session.OnLocationPositionChanged(info, index); + session.OnLocationPositionChanged(info, dataSource); TEST(my::AlmostEqualAbs(session.GetCompletionPercent(), 100., 0.5), ()); } } // namespace routing diff --git a/routing/speed_camera.cpp b/routing/speed_camera.cpp index 233e6703df..2dcf4ac42f 100644 --- a/routing/speed_camera.cpp +++ b/routing/speed_camera.cpp @@ -37,12 +37,11 @@ uint8_t ReadCameraRestriction(FeatureType & ft) return 0; } -uint8_t CheckCameraInPoint(m2::PointD const & point, DataSourceBase const & index) +uint8_t CheckCameraInPoint(m2::PointD const & point, DataSourceBase const & dataSource) { uint32_t speedLimit = kNoSpeedCamera; - auto const f = [&point, &speedLimit](FeatureType & ft) - { + auto const f = [&point, &speedLimit](FeatureType & ft) { if (ft.GetFeatureType() != feature::GEOM_POINT) return; @@ -55,10 +54,9 @@ uint8_t CheckCameraInPoint(m2::PointD const & point, DataSourceBase const & inde speedLimit = ReadCameraRestriction(ft); }; - index.ForEachInRect(f, - MercatorBounds::RectByCenterXYAndSizeInMeters(point, - kCameraCheckRadiusMeters), - scales::GetUpperScale()); + dataSource.ForEachInRect( + f, MercatorBounds::RectByCenterXYAndSizeInMeters(point, kCameraCheckRadiusMeters), + scales::GetUpperScale()); return speedLimit; } } // namespace routing diff --git a/routing/speed_camera.hpp b/routing/speed_camera.hpp index c6d27f0b40..175f84eefb 100644 --- a/routing/speed_camera.hpp +++ b/routing/speed_camera.hpp @@ -10,5 +10,5 @@ namespace routing { extern uint8_t const kNoSpeedCamera; -uint8_t CheckCameraInPoint(m2::PointD const & point, DataSourceBase const & index); +uint8_t CheckCameraInPoint(m2::PointD const & point, DataSourceBase const & dataSource); } // namespace routing diff --git a/routing/transit_graph_loader.cpp b/routing/transit_graph_loader.cpp index 08fe4c892f..c55820f019 100644 --- a/routing/transit_graph_loader.cpp +++ b/routing/transit_graph_loader.cpp @@ -27,7 +27,7 @@ namespace routing class TransitGraphLoaderImpl : public TransitGraphLoader { public: - TransitGraphLoaderImpl(DataSourceBase & index, shared_ptr numMwmIds, + TransitGraphLoaderImpl(DataSourceBase & dataSource, shared_ptr numMwmIds, shared_ptr estimator); // TransitGraphLoader overrides. @@ -39,15 +39,15 @@ public: private: unique_ptr CreateTransitGraph(NumMwmId mwmId, IndexGraph & indexGraph) const; - DataSourceBase & m_index; + DataSourceBase & m_dataSource; shared_ptr m_numMwmIds; shared_ptr m_estimator; unordered_map> m_graphs; }; -TransitGraphLoaderImpl::TransitGraphLoaderImpl(DataSourceBase & index, shared_ptr numMwmIds, +TransitGraphLoaderImpl::TransitGraphLoaderImpl(DataSourceBase & dataSource, shared_ptr numMwmIds, shared_ptr estimator) - : m_index(index), m_numMwmIds(numMwmIds), m_estimator(estimator) + : m_dataSource(dataSource), m_numMwmIds(numMwmIds), m_estimator(estimator) { } @@ -68,7 +68,7 @@ unique_ptr TransitGraphLoaderImpl::CreateTransitGraph(NumMwmId num IndexGraph & indexGraph) const { platform::CountryFile const & file = m_numMwmIds->GetFile(numMwmId); - MwmSet::MwmHandle handle = m_index.GetMwmHandleByCountryFile(file); + MwmSet::MwmHandle handle = m_dataSource.GetMwmHandleByCountryFile(file); if (!handle.IsAlive()) MYTHROW(RoutingException, ("Can't get mwm handle for", file)); @@ -101,11 +101,11 @@ unique_ptr TransitGraphLoaderImpl::CreateTransitGraph(NumMwmId num } // static -unique_ptr TransitGraphLoader::Create(DataSourceBase & index, +unique_ptr TransitGraphLoader::Create(DataSourceBase & dataSource, shared_ptr numMwmIds, shared_ptr estimator) { - return my::make_unique(index, numMwmIds, estimator); + return my::make_unique(dataSource, numMwmIds, estimator); } } // namespace routing diff --git a/routing/transit_graph_loader.hpp b/routing/transit_graph_loader.hpp index e077b39848..a4fdbcdfb6 100644 --- a/routing/transit_graph_loader.hpp +++ b/routing/transit_graph_loader.hpp @@ -20,7 +20,7 @@ public: virtual TransitGraph & GetTransitGraph(NumMwmId mwmId, IndexGraph & indexGraph) = 0; virtual void Clear() = 0; - static std::unique_ptr Create(DataSourceBase & index, + static std::unique_ptr Create(DataSourceBase & dataSource, std::shared_ptr numMwmIds, std::shared_ptr estimator); }; diff --git a/search/cities_boundaries_table.cpp b/search/cities_boundaries_table.cpp index c6e4592485..55d9c39c2c 100644 --- a/search/cities_boundaries_table.cpp +++ b/search/cities_boundaries_table.cpp @@ -32,7 +32,7 @@ bool CitiesBoundariesTable::Boundaries::HasPoint(m2::PointD const & p) const // CitiesBoundariesTable --------------------------------------------------------------------------- bool CitiesBoundariesTable::Load() { - auto handle = FindWorld(m_index); + auto handle = FindWorld(m_dataSource); if (!handle.IsAlive()) { LOG(LWARNING, ("Can't find World map file.")); diff --git a/search/cities_boundaries_table.hpp b/search/cities_boundaries_table.hpp index e105ce5a54..7c1634ebe7 100644 --- a/search/cities_boundaries_table.hpp +++ b/search/cities_boundaries_table.hpp @@ -58,7 +58,7 @@ public: double m_eps = 0.0; }; - explicit CitiesBoundariesTable(DataSourceBase const & index) : m_index(index) {} + explicit CitiesBoundariesTable(DataSourceBase const & dataSource) : m_dataSource(dataSource) {} bool Load(); @@ -69,7 +69,7 @@ public: bool Get(uint32_t fid, Boundaries & bs) const; private: - DataSourceBase const & m_index; + DataSourceBase const & m_dataSource; MwmSet::MwmId m_mwmId; std::unordered_map> m_table; double m_eps = 0.0; diff --git a/search/city_finder.cpp b/search/city_finder.cpp index a94c6e74ad..be34025cbc 100644 --- a/search/city_finder.cpp +++ b/search/city_finder.cpp @@ -6,10 +6,10 @@ using namespace std; namespace search { -CityFinder::CityFinder(DataSourceBase const & index) - : m_unusedBoundaries(index) +CityFinder::CityFinder(DataSourceBase const & dataSource) + : m_unusedBoundaries(dataSource) , m_unusedCache(m_cancellable) - , m_finder(index, m_unusedBoundaries, m_unusedCache) + , m_finder(dataSource, m_unusedBoundaries, m_unusedCache) { } diff --git a/search/city_finder.hpp b/search/city_finder.hpp index f043372a32..f7b38f3e52 100644 --- a/search/city_finder.hpp +++ b/search/city_finder.hpp @@ -21,7 +21,7 @@ public: // TODO (@milchakov): consider to reuse locality finder from search // engine. Otherwise, CityFinder won't benefit from approximated // cities boundaries. - explicit CityFinder(DataSourceBase const & index); + explicit CityFinder(DataSourceBase const & dataSource); std::string GetCityName(m2::PointD const & p, int8_t lang); FeatureID GetCityFeatureID(m2::PointD const & p); diff --git a/search/downloader_search_callback.cpp b/search/downloader_search_callback.cpp index 3988444243..a965aaf065 100644 --- a/search/downloader_search_callback.cpp +++ b/search/downloader_search_callback.cpp @@ -35,12 +35,12 @@ bool GetGroupCountryIdFromFeature(storage::Storage const & storage, FeatureType namespace search { -DownloaderSearchCallback::DownloaderSearchCallback(Delegate & delegate, DataSourceBase const & index, +DownloaderSearchCallback::DownloaderSearchCallback(Delegate & delegate, DataSourceBase const & dataSource, storage::CountryInfoGetter const & infoGetter, storage::Storage const & storage, storage::DownloaderSearchParams params) : m_delegate(delegate) - , m_index(index) + , m_dataSource(dataSource) , m_infoGetter(infoGetter) , m_storage(storage) , m_params(move(params)) @@ -60,7 +60,7 @@ void DownloaderSearchCallback::operator()(search::Results const & results) if (result.GetResultType() != search::Result::Type::LatLon) { FeatureID const & fid = result.GetFeatureID(); - EditableDataSource::FeaturesLoaderGuard loader(m_index, fid.m_mwmId); + EditableDataSource::FeaturesLoaderGuard loader(m_dataSource, fid.m_mwmId); FeatureType ft; if (!loader.GetFeatureByIndex(fid.m_index, ft)) { diff --git a/search/downloader_search_callback.hpp b/search/downloader_search_callback.hpp index 9a8074218a..555b67fd58 100644 --- a/search/downloader_search_callback.hpp +++ b/search/downloader_search_callback.hpp @@ -30,7 +30,7 @@ public: virtual void RunUITask(std::function fn) = 0; }; - DownloaderSearchCallback(Delegate & delegate, DataSourceBase const & index, + DownloaderSearchCallback(Delegate & delegate, DataSourceBase const & dataSource, storage::CountryInfoGetter const & infoGetter, storage::Storage const & storage, storage::DownloaderSearchParams params); @@ -39,7 +39,7 @@ public: private: Delegate & m_delegate; - DataSourceBase const & m_index; + DataSourceBase const & m_dataSource; storage::CountryInfoGetter const & m_infoGetter; storage::Storage const & m_storage; storage::DownloaderSearchParams m_params; diff --git a/search/editor_delegate.cpp b/search/editor_delegate.cpp index f60ce40d1c..7faf4c3463 100644 --- a/search/editor_delegate.cpp +++ b/search/editor_delegate.cpp @@ -9,16 +9,16 @@ namespace search { -EditorDelegate::EditorDelegate(DataSourceBase const & index) : m_index(index) {} +EditorDelegate::EditorDelegate(DataSourceBase const & dataSource) : m_dataSource(dataSource) {} MwmSet::MwmId EditorDelegate::GetMwmIdByMapName(string const & name) const { - return m_index.GetMwmIdByCountryFile(platform::CountryFile(name)); + return m_dataSource.GetMwmIdByCountryFile(platform::CountryFile(name)); } unique_ptr EditorDelegate::GetOriginalFeature(FeatureID const & fid) const { - EditableDataSource::FeaturesLoaderGuard guard(m_index, fid.m_mwmId); + EditableDataSource::FeaturesLoaderGuard guard(m_dataSource, fid.m_mwmId); auto feature = guard.GetOriginalFeatureByIndex(fid.m_index); if (feature) feature->ParseEverything(); @@ -28,7 +28,7 @@ unique_ptr EditorDelegate::GetOriginalFeature(FeatureID const & fid string EditorDelegate::GetOriginalFeatureStreet(FeatureType & ft) const { - search::ReverseGeocoder const coder(m_index); + search::ReverseGeocoder const coder(m_dataSource); auto const streets = coder.GetNearbyFeatureStreets(ft); if (streets.second < streets.first.size()) return streets.first[streets.second].m_name; @@ -39,6 +39,6 @@ void EditorDelegate::ForEachFeatureAtPoint(osm::Editor::FeatureTypeFn && fn, m2::PointD const & point) const { auto const kToleranceMeters = 1e-2; - indexer::ForEachFeatureAtPoint(m_index, move(fn), point, kToleranceMeters); + indexer::ForEachFeatureAtPoint(m_dataSource, move(fn), point, kToleranceMeters); } } // namespace search diff --git a/search/editor_delegate.hpp b/search/editor_delegate.hpp index 4a98743a42..333e500012 100644 --- a/search/editor_delegate.hpp +++ b/search/editor_delegate.hpp @@ -9,7 +9,7 @@ namespace search class EditorDelegate : public osm::Editor::Delegate { public: - EditorDelegate(DataSourceBase const & index); + EditorDelegate(DataSourceBase const & dataSource); // osm::Editor::Delegate overrides: MwmSet::MwmId GetMwmIdByMapName(string const & name) const override; @@ -19,6 +19,6 @@ public: m2::PointD const & point) const override; private: - DataSourceBase const & m_index; + DataSourceBase const & m_dataSource; }; } // namespace search diff --git a/search/engine.cpp b/search/engine.cpp index e9c08a2dea..f3a559cc2c 100644 --- a/search/engine.cpp +++ b/search/engine.cpp @@ -92,7 +92,7 @@ Engine::Params::Params(string const & locale, size_t numThreads) } // Engine ------------------------------------------------------------------------------------------ -Engine::Engine(DataSourceBase & index, CategoriesHolder const & categories, +Engine::Engine(DataSourceBase & dataSource, CategoriesHolder const & categories, storage::CountryInfoGetter const & infoGetter, Params const & params) : m_shutdown(false) { @@ -103,7 +103,7 @@ Engine::Engine(DataSourceBase & index, CategoriesHolder const & categories, m_contexts.resize(params.m_numThreads); for (size_t i = 0; i < params.m_numThreads; ++i) { - auto processor = make_unique(index, categories, m_suggests, infoGetter); + auto processor = make_unique(dataSource, categories, m_suggests, infoGetter); processor->SetPreferredLocale(params.m_locale); m_contexts[i].m_processor = move(processor); } diff --git a/search/engine.hpp b/search/engine.hpp index edc4430f53..ec5beb030c 100644 --- a/search/engine.hpp +++ b/search/engine.hpp @@ -89,8 +89,8 @@ public: size_t m_numThreads; }; - // Doesn't take ownership of index and categories. - Engine(DataSourceBase & index, CategoriesHolder const & categories, + // Doesn't take ownership of dataSource and categories. + Engine(DataSourceBase & dataSource, CategoriesHolder const & categories, storage::CountryInfoGetter const & infoGetter, Params const & params); ~Engine(); diff --git a/search/feature_loader.cpp b/search/feature_loader.cpp index 10fabe1949..9841aa4b26 100644 --- a/search/feature_loader.cpp +++ b/search/feature_loader.cpp @@ -6,7 +6,7 @@ namespace search { -FeatureLoader::FeatureLoader(DataSourceBase const & index) : m_index(index) {} +FeatureLoader::FeatureLoader(DataSourceBase const & dataSource) : m_dataSource(dataSource) {} bool FeatureLoader::Load(FeatureID const & id, FeatureType & ft) { @@ -14,7 +14,7 @@ bool FeatureLoader::Load(FeatureID const & id, FeatureType & ft) auto const & mwmId = id.m_mwmId; if (!m_guard || m_guard->GetId() != mwmId) - m_guard = my::make_unique(m_index, mwmId); + m_guard = my::make_unique(m_dataSource, mwmId); return m_guard->GetFeatureByIndex(id.m_index, ft); } diff --git a/search/feature_loader.hpp b/search/feature_loader.hpp index 4ab62f94cb..5d79a326e0 100644 --- a/search/feature_loader.hpp +++ b/search/feature_loader.hpp @@ -19,7 +19,7 @@ namespace search class FeatureLoader { public: - explicit FeatureLoader(DataSourceBase const & index); + explicit FeatureLoader(DataSourceBase const & dataSource); WARN_UNUSED_RESULT bool Load(FeatureID const & id, FeatureType & ft); @@ -28,11 +28,11 @@ public: void ForEachInRect(m2::RectD const & rect, std::function const & fn) { ASSERT(m_checker.CalledOnOriginalThread(), ()); - m_index.ForEachInRect(fn, rect, scales::GetUpperScale()); + m_dataSource.ForEachInRect(fn, rect, scales::GetUpperScale()); } private: - DataSourceBase const & m_index; + DataSourceBase const & m_dataSource; std::unique_ptr m_guard; ThreadChecker m_checker; diff --git a/search/features_layer_matcher.cpp b/search/features_layer_matcher.cpp index c82efd6111..b7974aaa00 100644 --- a/search/features_layer_matcher.cpp +++ b/search/features_layer_matcher.cpp @@ -13,11 +13,11 @@ namespace search /// even if there is no exact street written for this house. int constexpr kMaxApproxStreetDistanceM = 100; -FeaturesLayerMatcher::FeaturesLayerMatcher(DataSourceBase const & index, +FeaturesLayerMatcher::FeaturesLayerMatcher(DataSourceBase const & dataSource, ::base::Cancellable const & cancellable) : m_context(nullptr) , m_postcodes(nullptr) - , m_reverseGeocoder(index) + , m_reverseGeocoder(dataSource) , m_nearbyStreetsCache("FeatureToNearbyStreets") , m_matchingStreetsCache("BuildingToStreet") , m_loader(scales::GetUpperScale(), ReverseGeocoder::kLookupRadiusM) diff --git a/search/features_layer_matcher.hpp b/search/features_layer_matcher.hpp index 7742b6bb71..22aea70380 100644 --- a/search/features_layer_matcher.hpp +++ b/search/features_layer_matcher.hpp @@ -61,7 +61,7 @@ public: static int constexpr kBuildingRadiusMeters = 50; static int constexpr kStreetRadiusMeters = 100; - FeaturesLayerMatcher(DataSourceBase const & index, ::base::Cancellable const & cancellable); + FeaturesLayerMatcher(DataSourceBase const & dataSource, ::base::Cancellable const & cancellable); void SetContext(MwmContext * context); void SetPostcodes(CBV const * postcodes); diff --git a/search/geocoder.cpp b/search/geocoder.cpp index 0ee6a292f5..7a0624d963 100644 --- a/search/geocoder.cpp +++ b/search/geocoder.cpp @@ -336,10 +336,10 @@ size_t OrderCountries(m2::RectD const & pivot, vector> & inf } // namespace // Geocoder::Geocoder ------------------------------------------------------------------------------ -Geocoder::Geocoder(DataSourceBase const & index, storage::CountryInfoGetter const & infoGetter, +Geocoder::Geocoder(DataSourceBase const & dataSource, storage::CountryInfoGetter const & infoGetter, CategoriesHolder const & categories, PreRanker & preRanker, VillagesCache & villagesCache, ::base::Cancellable const & cancellable) - : m_index(index) + : m_dataSource(dataSource) , m_infoGetter(infoGetter) , m_categories(categories) , m_streetsCache(cancellable) @@ -414,7 +414,7 @@ void Geocoder::GoEverywhere() return; vector> infos; - m_index.GetMwmsInfo(infos); + m_dataSource.GetMwmsInfo(infos); GoImpl(infos, false /* inViewport */); } @@ -425,7 +425,7 @@ void Geocoder::GoInViewport() return; vector> infos; - m_index.GetMwmsInfo(infos); + m_dataSource.GetMwmsInfo(infos); my::EraseIf(infos, [this](shared_ptr const & info) { @@ -473,7 +473,7 @@ void Geocoder::GoImpl(vector> & infos, bool inViewport) m_cities.clear(); for (auto & regions : m_regions) regions.clear(); - MwmSet::MwmHandle handle = FindWorld(m_index, infos); + MwmSet::MwmHandle handle = FindWorld(m_dataSource, infos); if (handle.IsAlive()) { auto & value = *handle.GetValue(); @@ -525,7 +525,7 @@ void Geocoder::GoImpl(vector> & infos, bool inViewport) { it = m_matchersCache .insert(make_pair(m_context->GetId(), - my::make_unique(m_index, m_cancellable))) + my::make_unique(m_dataSource, m_cancellable))) .first; } m_matcher = it->second.get(); @@ -754,7 +754,7 @@ void Geocoder::ForEachCountry(vector> const & infos, TFn && if (info->GetType() == MwmInfo::COUNTRY && m_params.m_mode == Mode::Downloader) continue; - auto handle = m_index.GetMwmHandleById(MwmSet::MwmId(info)); + auto handle = m_dataSource.GetMwmHandleById(MwmSet::MwmId(info)); if (!handle.IsAlive()) continue; auto & value = *handle.GetValue(); diff --git a/search/geocoder.hpp b/search/geocoder.hpp index f3985b19af..0d280c9e3f 100644 --- a/search/geocoder.hpp +++ b/search/geocoder.hpp @@ -87,7 +87,7 @@ public: shared_ptr m_tracer; }; - Geocoder(DataSourceBase const & index, storage::CountryInfoGetter const & infoGetter, + Geocoder(DataSourceBase const & dataSource, storage::CountryInfoGetter const & infoGetter, CategoriesHolder const & categories, PreRanker & preRanker, VillagesCache & villagesCache, ::base::Cancellable const & cancellable); ~Geocoder(); @@ -239,7 +239,7 @@ private: WARN_UNUSED_RESULT bool GetTypeInGeocoding(BaseContext const & ctx, uint32_t featureId, Model::Type & type); - DataSourceBase const & m_index; + DataSourceBase const & m_dataSource; storage::CountryInfoGetter const & m_infoGetter; CategoriesHolder const & m_categories; diff --git a/search/house_detector.cpp b/search/house_detector.cpp index e540198a3b..3000b356d9 100644 --- a/search/house_detector.cpp +++ b/search/house_detector.cpp @@ -294,8 +294,8 @@ void Street::SortHousesProjection() sort(m_houses.begin(), m_houses.end(), &LessStreetDistance); } -HouseDetector::HouseDetector(DataSourceBase const & index) - : m_loader(index), m_streetNum(0) +HouseDetector::HouseDetector(DataSourceBase const & dataSource) + : m_loader(dataSource), m_streetNum(0) { // default value for conversions SetMetres2Mercator(360.0 / 40.0E06); diff --git a/search/house_detector.hpp b/search/house_detector.hpp index 2062886f8e..8e72cdb43b 100644 --- a/search/house_detector.hpp +++ b/search/house_detector.hpp @@ -237,7 +237,7 @@ class HouseDetector double GetApprLengthMeters(int index) const; public: - HouseDetector(DataSourceBase const & index); + HouseDetector(DataSourceBase const & dataSource); ~HouseDetector(); int LoadStreets(vector const & ids); diff --git a/search/locality_finder.cpp b/search/locality_finder.cpp index 67d80f58dc..1d01c12605 100644 --- a/search/locality_finder.cpp +++ b/search/locality_finder.cpp @@ -206,9 +206,9 @@ void LocalityFinder::Holder::Clear() } // LocalityFinder ---------------------------------------------------------------------------------- -LocalityFinder::LocalityFinder(DataSourceBase const & index, CitiesBoundariesTable const & boundariesTable, +LocalityFinder::LocalityFinder(DataSourceBase const & dataSource, CitiesBoundariesTable const & boundariesTable, VillagesCache & villagesCache) - : m_index(index) + : m_dataSource(dataSource) , m_boundariesTable(boundariesTable) , m_villagesCache(villagesCache) , m_cities(kMaxCityRadiusMeters) @@ -237,7 +237,7 @@ void LocalityFinder::LoadVicinity(m2::PointD const & p, bool loadCities, bool lo if (loadCities) { m2::RectD const crect = m_cities.GetDRect(p); - auto handle = m_index.GetMwmHandleById(m_worldId); + auto handle = m_dataSource.GetMwmHandleById(m_worldId); if (handle.IsAlive()) { auto const & value = *handle.GetValue(); @@ -258,7 +258,7 @@ void LocalityFinder::LoadVicinity(m2::PointD const & p, bool loadCities, bool lo { m2::RectD const vrect = m_villages.GetDRect(p); m_maps.ForEachInRect(m2::RectD(p, p), [&](MwmSet::MwmId const & id) { - auto handle = m_index.GetMwmHandleById(id); + auto handle = m_dataSource.GetMwmHandleById(id); if (!handle.IsAlive()) return; @@ -278,7 +278,7 @@ void LocalityFinder::UpdateMaps() return; vector> mwmsInfo; - m_index.GetMwmsInfo(mwmsInfo); + m_dataSource.GetMwmsInfo(mwmsInfo); for (auto const & info : mwmsInfo) { MwmSet::MwmId id(info); diff --git a/search/locality_finder.hpp b/search/locality_finder.hpp index 640b304fc2..371e69f66a 100644 --- a/search/locality_finder.hpp +++ b/search/locality_finder.hpp @@ -100,7 +100,7 @@ public: DISALLOW_COPY_AND_MOVE(Holder); }; - LocalityFinder(DataSourceBase const & index, CitiesBoundariesTable const & boundaries, + LocalityFinder(DataSourceBase const & dataSource, CitiesBoundariesTable const & boundaries, VillagesCache & villagesCache); template @@ -125,7 +125,7 @@ private: void LoadVicinity(m2::PointD const & p, bool loadCities, bool loadVillages); void UpdateMaps(); - DataSourceBase const & m_index; + DataSourceBase const & m_dataSource; CitiesBoundariesTable const & m_boundariesTable; VillagesCache & m_villagesCache; diff --git a/search/nested_rects_cache.cpp b/search/nested_rects_cache.cpp index a3e2b8b294..d7d53ab67b 100644 --- a/search/nested_rects_cache.cpp +++ b/search/nested_rects_cache.cpp @@ -19,8 +19,8 @@ namespace double const kPositionToleranceMeters = 15.0; } // namespace -NestedRectsCache::NestedRectsCache(DataSourceBase const & index) - : m_index(index), m_scale(0), m_position(0, 0), m_valid(false) +NestedRectsCache::NestedRectsCache(DataSourceBase const & dataSource) + : m_dataSource(dataSource), m_scale(0), m_position(0, 0), m_valid(false) { } @@ -107,7 +107,7 @@ void NestedRectsCache::Update() } lastFeatures->push_back(id.m_index); }; - m_index.ForEachFeatureIDInRect(addId, rect, m_scale); + m_dataSource.ForEachFeatureIDInRect(addId, rect, m_scale); for (auto & kv : bucket) sort(kv.second.begin(), kv.second.end()); } diff --git a/search/nested_rects_cache.hpp b/search/nested_rects_cache.hpp index 02b38acb18..10944797b2 100644 --- a/search/nested_rects_cache.hpp +++ b/search/nested_rects_cache.hpp @@ -14,7 +14,7 @@ namespace search class NestedRectsCache { public: - explicit NestedRectsCache(DataSourceBase const & index); + explicit NestedRectsCache(DataSourceBase const & dataSource); void SetPosition(m2::PointD const & position, int scale); @@ -37,7 +37,7 @@ private: void Update(); - DataSourceBase const & m_index; + DataSourceBase const & m_dataSource; int m_scale; m2::PointD m_position; bool m_valid; diff --git a/search/pre_ranker.cpp b/search/pre_ranker.cpp index 9a04c66a4d..5d7a7ccd33 100644 --- a/search/pre_ranker.cpp +++ b/search/pre_ranker.cpp @@ -45,8 +45,8 @@ void SweepNearbyResults(double eps, set const & prevEmit, vector m_results; Params m_params; diff --git a/search/processor.cpp b/search/processor.cpp index ceb23c0f34..fd8052784a 100644 --- a/search/processor.cpp +++ b/search/processor.cpp @@ -141,19 +141,19 @@ size_t const Processor::kPreResultsCount = 200; double const Processor::kMinViewportRadiusM = 5.0 * 1000; double const Processor::kMaxViewportRadiusM = 50.0 * 1000; -Processor::Processor(DataSourceBase const & index, CategoriesHolder const & categories, +Processor::Processor(DataSourceBase const & dataSource, CategoriesHolder const & categories, vector const & suggests, storage::CountryInfoGetter const & infoGetter) : m_categories(categories) , m_infoGetter(infoGetter) , m_position(0, 0) , m_villagesCache(static_cast<::base::Cancellable const &>(*this)) - , m_citiesBoundaries(index) + , m_citiesBoundaries(dataSource) , m_keywordsScorer(LanguageTier::LANGUAGE_TIER_COUNT) - , m_ranker(index, m_citiesBoundaries, infoGetter, m_keywordsScorer, m_emitter, categories, + , m_ranker(dataSource, m_citiesBoundaries, infoGetter, m_keywordsScorer, m_emitter, categories, suggests, m_villagesCache, static_cast<::base::Cancellable const &>(*this)) - , m_preRanker(index, m_ranker) - , m_geocoder(index, infoGetter, categories, m_preRanker, m_villagesCache, + , m_preRanker(dataSource, m_ranker) + , m_geocoder(dataSource, infoGetter, categories, m_preRanker, m_villagesCache, static_cast<::base::Cancellable const &>(*this)) , m_bookmarksProcessor(m_emitter, static_cast<::base::Cancellable const &>(*this)) { diff --git a/search/processor.hpp b/search/processor.hpp index 522272d271..588058efa1 100644 --- a/search/processor.hpp +++ b/search/processor.hpp @@ -63,7 +63,7 @@ public: static double const kMinViewportRadiusM; static double const kMaxViewportRadiusM; - Processor(DataSourceBase const & index, CategoriesHolder const & categories, + Processor(DataSourceBase const & dataSource, CategoriesHolder const & categories, std::vector const & suggests, storage::CountryInfoGetter const & infoGetter); void SetViewport(m2::RectD const & viewport); diff --git a/search/pysearch/bindings.cpp b/search/pysearch/bindings.cpp index b3c93636ab..cf6208f2ed 100644 --- a/search/pysearch/bindings.cpp +++ b/search/pysearch/bindings.cpp @@ -184,9 +184,9 @@ unique_ptr CreateCountryInfoGetter() struct Context { - Context() : m_engine(m_index, CreateCountryInfoGetter(), search::Engine::Params{}) {} + Context() : m_engine(m_dataSource, CreateCountryInfoGetter(), search::Engine::Params{}) {} - DataSource m_index; + DataSource m_dataSource; search::tests_support::TestSearchEngine m_engine; }; @@ -200,7 +200,7 @@ struct SearchEngineProxy for (auto & mwm : mwms) { mwm.SyncWithDisk(); - m_context->m_index.RegisterMap(mwm); + m_context->m_dataSource.RegisterMap(mwm); } } diff --git a/search/rank_table_cache.cpp b/search/rank_table_cache.cpp index 23d885d777..9af61e7aa9 100644 --- a/search/rank_table_cache.cpp +++ b/search/rank_table_cache.cpp @@ -7,13 +7,13 @@ namespace search { -RankTable const & RankTableCache::Get(DataSourceBase & index, TId const & mwmId) +RankTable const & RankTableCache::Get(DataSourceBase & dataSource, TId const & mwmId) { auto const it = m_ranks.find(TKey(mwmId)); if (it != m_ranks.end()) return *it->second; - TKey handle(index.GetMwmHandleById(mwmId)); + TKey handle(dataSource.GetMwmHandleById(mwmId)); auto table = RankTable::Load(handle.GetValue()->m_cont); if (!table) table.reset(new DummyRankTable()); diff --git a/search/rank_table_cache.hpp b/search/rank_table_cache.hpp index 13b7d59979..c7b8d691ee 100644 --- a/search/rank_table_cache.hpp +++ b/search/rank_table_cache.hpp @@ -29,7 +29,7 @@ class RankTableCache public: RankTableCache() = default; - RankTable const & Get(DataSourceBase & index, TId const & mwmId); + RankTable const & Get(DataSourceBase & dataSource, TId const & mwmId); void Remove(TId const & id); void Clear(); diff --git a/search/ranker.cpp b/search/ranker.cpp index b4c39cb4c8..1931b9dbb1 100644 --- a/search/ranker.cpp +++ b/search/ranker.cpp @@ -211,7 +211,7 @@ class RankerResultMaker { using LoaderGuard = EditableDataSource::FeaturesLoaderGuard; Ranker & m_ranker; - DataSourceBase const & m_index; + DataSourceBase const & m_dataSource; Geocoder::Params const & m_params; storage::CountryInfoGetter const & m_infoGetter; @@ -220,7 +220,7 @@ class RankerResultMaker bool LoadFeature(FeatureID const & id, FeatureType & ft) { if (!m_loader || m_loader->GetId() != id.m_mwmId) - m_loader = make_unique(m_index, id.m_mwmId); + m_loader = make_unique(m_dataSource, id.m_mwmId); if (!m_loader->GetFeatureByIndex(id.m_index, ft)) return false; @@ -331,9 +331,9 @@ class RankerResultMaker } public: - RankerResultMaker(Ranker & ranker, DataSourceBase const & index, + RankerResultMaker(Ranker & ranker, DataSourceBase const & dataSource, storage::CountryInfoGetter const & infoGetter, Geocoder::Params const & params) - : m_ranker(ranker), m_index(index), m_params(params), m_infoGetter(infoGetter) + : m_ranker(ranker), m_dataSource(dataSource), m_params(params), m_infoGetter(infoGetter) { } @@ -358,16 +358,16 @@ public: } }; -Ranker::Ranker(DataSourceBase const & index, CitiesBoundariesTable const & boundariesTable, +Ranker::Ranker(DataSourceBase const & dataSource, CitiesBoundariesTable const & boundariesTable, storage::CountryInfoGetter const & infoGetter, KeywordLangMatcher & keywordsScorer, Emitter & emitter, CategoriesHolder const & categories, vector const & suggests, VillagesCache & villagesCache, ::base::Cancellable const & cancellable) - : m_reverseGeocoder(index) + : m_reverseGeocoder(dataSource) , m_cancellable(cancellable) , m_keywordsScorer(keywordsScorer) - , m_localities(index, boundariesTable, villagesCache) - , m_index(index) + , m_localities(dataSource, boundariesTable, villagesCache) + , m_dataSource(dataSource) , m_infoGetter(infoGetter) , m_emitter(emitter) , m_categories(categories) @@ -542,7 +542,7 @@ void Ranker::LoadCountriesTree() { m_regionInfoGetter.LoadCountriesTree(); } void Ranker::MakeRankerResults(Geocoder::Params const & geocoderParams, vector & results) { - RankerResultMaker maker(*this, m_index, m_infoGetter, geocoderParams); + RankerResultMaker maker(*this, m_dataSource, m_infoGetter, geocoderParams); for (auto const & r : m_preRankerResults) { auto p = maker(r); diff --git a/search/ranker.hpp b/search/ranker.hpp index 8bc4ecbb77..9cf11f09fd 100644 --- a/search/ranker.hpp +++ b/search/ranker.hpp @@ -79,7 +79,7 @@ public: size_t m_limit = 0; }; - Ranker(DataSourceBase const & index, CitiesBoundariesTable const & boundariesTable, + Ranker(DataSourceBase const & dataSource, CitiesBoundariesTable const & boundariesTable, storage::CountryInfoGetter const & infoGetter, KeywordLangMatcher & keywordsScorer, Emitter & emitter, CategoriesHolder const & categories, std::vector const & suggests, VillagesCache & villagesCache, @@ -134,7 +134,7 @@ private: int8_t m_localeCode; RegionInfoGetter m_regionInfoGetter; - DataSourceBase const & m_index; + DataSourceBase const & m_dataSource; storage::CountryInfoGetter const & m_infoGetter; Emitter & m_emitter; CategoriesHolder const & m_categories; diff --git a/search/reverse_geocoder.cpp b/search/reverse_geocoder.cpp index 8638dfd59b..33412e094c 100644 --- a/search/reverse_geocoder.cpp +++ b/search/reverse_geocoder.cpp @@ -24,7 +24,7 @@ int constexpr kQueryScale = scales::GetUpperScale(); size_t constexpr kMaxNumTriesToApproxAddress = 10; } // namespace -ReverseGeocoder::ReverseGeocoder(DataSourceBase const & index) : m_index(index) {} +ReverseGeocoder::ReverseGeocoder(DataSourceBase const & dataSource) : m_dataSource(dataSource) {} void ReverseGeocoder::GetNearbyStreets(MwmSet::MwmId const & id, m2::PointD const & center, vector & streets) const @@ -48,7 +48,7 @@ void ReverseGeocoder::GetNearbyStreets(MwmSet::MwmId const & id, m2::PointD cons streets.emplace_back(ft.GetID(), feature::GetMinDistanceMeters(ft, center), name); }; - MwmSet::MwmHandle mwmHandle = m_index.GetMwmHandleById(id); + MwmSet::MwmHandle mwmHandle = m_dataSource.GetMwmHandleById(id); if (mwmHandle.IsAlive()) { search::MwmContext(move(mwmHandle)).ForEachFeature(rect, addStreet); @@ -102,7 +102,7 @@ ReverseGeocoder::GetNearbyFeatureStreets(FeatureType & ft) const GetNearbyStreets(ft, result.first); - HouseTable table(m_index); + HouseTable table(m_dataSource); if (!table.Get(ft.GetID(), result.second)) result.second = numeric_limits::max(); @@ -114,7 +114,7 @@ void ReverseGeocoder::GetNearbyAddress(m2::PointD const & center, Address & addr vector buildings; GetNearbyBuildings(center, buildings); - HouseTable table(m_index); + HouseTable table(m_dataSource); size_t triesCount = 0; for (auto const & b : buildings) @@ -130,7 +130,7 @@ bool ReverseGeocoder::GetExactAddress(FeatureType const & ft, Address & addr) co { if (ft.GetHouseNumber().empty()) return false; - HouseTable table(m_index); + HouseTable table(m_dataSource); return GetNearbyAddress(table, FromFeature(ft, 0.0 /* distMeters */), addr); } @@ -174,7 +174,7 @@ void ReverseGeocoder::GetNearbyBuildings(m2::PointD const & center, vector m_table; MwmSet::MwmHandle m_handle; public: - explicit HouseTable(DataSourceBase const & index) : m_index(index) {} + explicit HouseTable(DataSourceBase const & dataSource) : m_dataSource(dataSource) {} bool Get(FeatureID const & fid, uint32_t & streetIndex); }; diff --git a/search/search_integration_tests/downloader_search_test.cpp b/search/search_integration_tests/downloader_search_test.cpp index da8e234648..7462a7ef39 100644 --- a/search/search_integration_tests/downloader_search_test.cpp +++ b/search/search_integration_tests/downloader_search_test.cpp @@ -106,10 +106,10 @@ public: class DownloaderSearchRequest : public TestSearchRequest, public TestDelegate { public: - DownloaderSearchRequest(DataSourceBase & index, TestSearchEngine & engine, string const & query) + DownloaderSearchRequest(DataSourceBase & dataSource, TestSearchEngine & engine, string const & query) : TestSearchRequest(engine, MakeSearchParams(query)) , m_storage(kCountriesTxt, make_unique()) - , m_downloaderCallback(static_cast(*this), index, + , m_downloaderCallback(static_cast(*this), dataSource, m_engine.GetCountryInfoGetter(), m_storage, MakeDownloaderParams(query)) { SetCustomOnResults(bind(&DownloaderSearchRequest::OnResultsDownloader, this, placeholders::_1)); @@ -221,7 +221,7 @@ UNIT_CLASS_TEST(DownloaderSearchTest, Smoke) BuildWorld(); { - DownloaderSearchRequest request(m_index, m_engine, "square one"); + DownloaderSearchRequest request(m_dataSource, m_engine, "square one"); request.Run(); TestResults(request.GetResults(), @@ -229,7 +229,7 @@ UNIT_CLASS_TEST(DownloaderSearchTest, Smoke) } { - DownloaderSearchRequest request(m_index, m_engine, "shortpondland"); + DownloaderSearchRequest request(m_dataSource, m_engine, "shortpondland"); request.Run(); TestResults(request.GetResults(), @@ -237,14 +237,14 @@ UNIT_CLASS_TEST(DownloaderSearchTest, Smoke) } { - DownloaderSearchRequest request(m_index, m_engine, "flatland"); + DownloaderSearchRequest request(m_dataSource, m_engine, "flatland"); request.Run(); TestResults(request.GetResults(), {storage::DownloaderSearchResult("Flatland", "Flatland")}); } { - DownloaderSearchRequest request(m_index, m_engine, "square"); + DownloaderSearchRequest request(m_dataSource, m_engine, "square"); request.Run(); TestResults(request.GetResults(), diff --git a/search/search_integration_tests/generate_tests.cpp b/search/search_integration_tests/generate_tests.cpp index 2099365100..c645521a8a 100644 --- a/search/search_integration_tests/generate_tests.cpp +++ b/search/search_integration_tests/generate_tests.cpp @@ -63,8 +63,8 @@ UNIT_CLASS_TEST(GenerateTest, GenerateDeprecatedTypes) MakeFeature(builder, {"shop", "estate_agent"}, {2, 2}); } - DataSource index; - TEST_EQUAL(index.Register(file).second, MwmSet::RegResult::Success, ()); + DataSource dataSource; + TEST_EQUAL(dataSource.Register(file).second, MwmSet::RegResult::Success, ()); // New types. StringIL arr[] = {{"shop"}, {"office"}}; @@ -79,7 +79,7 @@ UNIT_CLASS_TEST(GenerateTest, GenerateDeprecatedTypes) ++count; ft.ForEachType([&](uint32_t t) { TEST(types.count(t) > 0, (cl.GetReadableObjectName(t))); }); }; - index.ForEachInScale(fn, scales::GetUpperScale()); + dataSource.ForEachInScale(fn, scales::GetUpperScale()); TEST_EQUAL(count, 3, ()); diff --git a/search/search_integration_tests/pre_ranker_test.cpp b/search/search_integration_tests/pre_ranker_test.cpp index dca92daf93..637e778590 100644 --- a/search/search_integration_tests/pre_ranker_test.cpp +++ b/search/search_integration_tests/pre_ranker_test.cpp @@ -52,11 +52,11 @@ namespace class TestRanker : public Ranker { public: - TestRanker(DataSourceBase & index, storage::CountryInfoGetter & infoGetter, + TestRanker(DataSourceBase & dataSource, storage::CountryInfoGetter & infoGetter, CitiesBoundariesTable const & boundariesTable, KeywordLangMatcher & keywordsScorer, Emitter & emitter, vector const & suggests, VillagesCache & villagesCache, ::base::Cancellable const & cancellable, vector & results) - : Ranker(index, boundariesTable, infoGetter, keywordsScorer, emitter, GetDefaultCategories(), + : Ranker(dataSource, boundariesTable, infoGetter, keywordsScorer, emitter, GetDefaultCategories(), suggests, villagesCache, cancellable) , m_results(results) { @@ -122,13 +122,13 @@ UNIT_CLASS_TEST(PreRankerTest, Smoke) vector results; Emitter emitter; - CitiesBoundariesTable boundariesTable(m_index); + CitiesBoundariesTable boundariesTable(m_dataSource); VillagesCache villagesCache(m_cancellable); KeywordLangMatcher keywordsScorer(0 /* maxLanguageTiers */); - TestRanker ranker(m_index, m_engine.GetCountryInfoGetter(), boundariesTable, keywordsScorer, + TestRanker ranker(m_dataSource, m_engine.GetCountryInfoGetter(), boundariesTable, keywordsScorer, emitter, m_suggests, villagesCache, m_cancellable, results); - PreRanker preRanker(m_index, ranker); + PreRanker preRanker(m_dataSource, ranker); PreRanker::Params params; params.m_viewport = kViewport; params.m_accuratePivotCenter = kPivot; diff --git a/search/search_integration_tests/processor_test.cpp b/search/search_integration_tests/processor_test.cpp index 0f471bb296..bf250247d2 100644 --- a/search/search_integration_tests/processor_test.cpp +++ b/search/search_integration_tests/processor_test.cpp @@ -587,7 +587,7 @@ UNIT_CLASS_TEST(ProcessorTest, TestPostcodes) // Tests that postcode is added to the search index. { - MwmContext context(m_index.GetMwmHandleById(countryId)); + MwmContext context(m_dataSource.GetMwmHandleById(countryId)); ::base::Cancellable cancellable; QueryParams params; @@ -605,7 +605,7 @@ UNIT_CLASS_TEST(ProcessorTest, TestPostcodes) while (!features->GetBit(index)) ++index; - EditableDataSource::FeaturesLoaderGuard loader(m_index, countryId); + EditableDataSource::FeaturesLoaderGuard loader(m_dataSource, countryId); FeatureType ft; TEST(loader.GetFeatureByIndex(::base::checked_cast(index), ft), ()); @@ -702,7 +702,7 @@ UNIT_CLASS_TEST(ProcessorTest, TestCategories) TEST(ResultsMatch(request->Results(), rules), ()); for (auto const & result : request->Results()) { - EditableDataSource::FeaturesLoaderGuard loader(m_index, wonderlandId); + EditableDataSource::FeaturesLoaderGuard loader(m_dataSource, wonderlandId); FeatureType ft; TEST(loader.GetFeatureByIndex(result.GetFeatureID().m_index, ft), ()); @@ -1141,7 +1141,7 @@ UNIT_CLASS_TEST(ProcessorTest, CityBoundaryLoad) TEST(ResultsMatch("moscow", "en", rules), ()); } - CitiesBoundariesTable table(m_index); + CitiesBoundariesTable table(m_dataSource); TEST(table.Load(), ()); TEST(table.Has(0 /* fid */), ()); TEST(!table.Has(10 /* fid */), ()); diff --git a/search/search_quality/assessment_tool/main_model.cpp b/search/search_quality/assessment_tool/main_model.cpp index a749b1a708..822d839d2d 100644 --- a/search/search_quality/assessment_tool/main_model.cpp +++ b/search/search_quality/assessment_tool/main_model.cpp @@ -30,8 +30,8 @@ using namespace std; // MainModel --------------------------------------------------------------------------------------- MainModel::MainModel(Framework & framework) : m_framework(framework) - , m_index(m_framework.GetIndex()) - , m_loader(m_index) + , m_dataSource(m_framework.GetDataSource()) + , m_loader(m_dataSource) , m_contexts( [this](size_t sampleIndex, Edits::Update const & update) { OnUpdate(View::ResultType::Found, sampleIndex, update); @@ -147,7 +147,7 @@ void MainModel::OnSampleSelected(int index) if (results.IsEndedNormal()) { // Can't use m_loader here due to thread-safety issues. - search::FeatureLoader loader(m_index); + search::FeatureLoader loader(m_dataSource); search::Matcher matcher(loader); vector const actual(results.begin(), results.end()); diff --git a/search/search_quality/assessment_tool/main_model.hpp b/search/search_quality/assessment_tool/main_model.hpp index d45aa717f0..00d3160590 100644 --- a/search/search_quality/assessment_tool/main_model.hpp +++ b/search/search_quality/assessment_tool/main_model.hpp @@ -64,7 +64,7 @@ private: void ForAnyMatchingEntry(Context & context, FeatureID const & id, Fn && fn); Framework & m_framework; - DataSourceBase const & m_index; + DataSourceBase const & m_dataSource; search::FeatureLoader m_loader; ContextList m_contexts; diff --git a/search/search_quality/features_collector_tool/features_collector_tool.cpp b/search/search_quality/features_collector_tool/features_collector_tool.cpp index a5ff890b6d..6b188678e9 100644 --- a/search/search_quality/features_collector_tool/features_collector_tool.cpp +++ b/search/search_quality/features_collector_tool/features_collector_tool.cpp @@ -152,7 +152,7 @@ int main(int argc, char * argv[]) } classificator::Load(); - DataSource index; + DataSource dataSource; vector mwms; platform::FindAllLocalMapsAndCleanup(numeric_limits::max() /* the latest version */, @@ -160,13 +160,13 @@ int main(int argc, char * argv[]) for (auto & mwm : mwms) { mwm.SyncWithDisk(); - index.RegisterMap(mwm); + dataSource.RegisterMap(mwm); } - TestSearchEngine engine(index, move(infoGetter), Engine::Params{}); + TestSearchEngine engine(dataSource, move(infoGetter), Engine::Params{}); vector stats(samples.size()); - FeatureLoader loader(index); + FeatureLoader loader(dataSource); Matcher matcher(loader); cout << "SampleId,"; diff --git a/search/search_quality/search_quality_tool/search_quality_tool.cpp b/search/search_quality/search_quality_tool/search_quality_tool.cpp index 47f9fd9a1f..2a93578cd1 100644 --- a/search/search_quality/search_quality_tool/search_quality_tool.cpp +++ b/search/search_quality/search_quality_tool/search_quality_tool.cpp @@ -197,11 +197,11 @@ void Split(string const & s, char delim, vector & parts) // Returns the position of the result that is expected to be found by geocoder completeness // tests in the |result| vector or -1 if it does not occur there. -int FindResult(DataSourceBase & index, string const & mwmName, uint32_t const featureId, double const lat, +int FindResult(DataSourceBase & dataSource, string const & mwmName, uint32_t const featureId, double const lat, double const lon, vector const & results) { CHECK_LESS_OR_EQUAL(results.size(), numeric_limits::max(), ()); - auto const mwmId = index.GetMwmIdByCountryFile(platform::CountryFile(mwmName)); + auto const mwmId = dataSource.GetMwmIdByCountryFile(platform::CountryFile(mwmName)); FeatureID const expectedFeatureId(mwmId, featureId); for (size_t i = 0; i < results.size(); ++i) { @@ -279,7 +279,7 @@ void ParseCompletenessQuery(string & s, CompletenessQuery & q) // from |path|, executes them against the |engine| with viewport set to |viewport| // and reports the number of queries whose expected result is among the returned results. // Exact feature id is expected, but a close enough (lat, lon) is good too. -void CheckCompleteness(string const & path, m2::RectD const & viewport, DataSourceBase & index, +void CheckCompleteness(string const & path, m2::RectD const & viewport, DataSourceBase & dataSource, TestSearchEngine & engine) { my::ScopedLogAbortLevelChanger const logAbortLevel(LCRITICAL); @@ -322,7 +322,7 @@ void CheckCompleteness(string const & path, m2::RectD const & viewport, DataSour LOG(LDEBUG, (q.m_query, q.m_request->Results())); int pos = - FindResult(index, q.m_mwmName, q.m_featureId, q.m_lat, q.m_lon, q.m_request->Results()); + FindResult(dataSource, q.m_mwmName, q.m_featureId, q.m_lat, q.m_lon, q.m_request->Results()); if (pos >= 0) ++expectedResultsFound; if (pos == 0) @@ -379,7 +379,7 @@ int main(int argc, char * argv[]) params.m_locale = FLAGS_locale; params.m_numThreads = FLAGS_num_threads; - DataSource index; + DataSource dataSource; vector mwms; if (!FLAGS_mwm_list_path.empty()) @@ -401,11 +401,11 @@ int main(int argc, char * argv[]) { mwm.SyncWithDisk(); cout << mwm.GetCountryName() << " " << ReadVersionFromHeader(mwm) << endl; - index.RegisterMap(mwm); + dataSource.RegisterMap(mwm); } cout << endl; - TestSearchEngine engine(index, move(infoGetter), params); + TestSearchEngine engine(dataSource, move(infoGetter), params); m2::RectD viewport; { @@ -425,7 +425,7 @@ int main(int argc, char * argv[]) if (!FLAGS_check_completeness.empty()) { - CheckCompleteness(FLAGS_check_completeness, viewport, index, engine); + CheckCompleteness(FLAGS_check_completeness, viewport, dataSource, engine); return 0; } diff --git a/search/search_tests/house_detector_tests.cpp b/search/search_tests/house_detector_tests.cpp index ccfc9d3f26..3775ebab9d 100644 --- a/search/search_tests/house_detector_tests.cpp +++ b/search/search_tests/house_detector_tests.cpp @@ -187,67 +187,67 @@ UNIT_TEST(HS_StreetsMerge) { classificator::Load(); - DataSource index; + DataSource dataSource; LocalCountryFile localFile(LocalCountryFile::MakeForTesting("minsk-pass")); // Clean indexes to avoid jenkins errors. platform::CountryIndexes::DeleteFromDisk(localFile); - auto const p = index.Register(localFile); + auto const p = dataSource.Register(localFile); TEST(p.first.IsAlive(), ()); TEST_EQUAL(MwmSet::RegResult::Success, p.second, ()); { - search::HouseDetector houser(index); + search::HouseDetector houser(dataSource); StreetIDsByName toDo; toDo.streetNames.push_back("улица Володарского"); - index.ForEachInScale([&toDo](FeatureType & ft) { toDo(ft); }, scales::GetUpperScale()); + dataSource.ForEachInScale([&toDo](FeatureType & ft) { toDo(ft); }, scales::GetUpperScale()); houser.LoadStreets(toDo.GetFeatureIDs()); TEST_EQUAL(houser.MergeStreets(), 1, ()); } { - search::HouseDetector houser(index); + search::HouseDetector houser(dataSource); StreetIDsByName toDo; toDo.streetNames.push_back("Московская улица"); - index.ForEachInScale([&toDo](FeatureType & ft) { toDo(ft); }, scales::GetUpperScale()); + dataSource.ForEachInScale([&toDo](FeatureType & ft) { toDo(ft); }, scales::GetUpperScale()); houser.LoadStreets(toDo.GetFeatureIDs()); TEST_GREATER_OR_EQUAL(houser.MergeStreets(), 1, ()); TEST_LESS_OR_EQUAL(houser.MergeStreets(), 3, ()); } { - search::HouseDetector houser(index); + search::HouseDetector houser(dataSource); StreetIDsByName toDo; toDo.streetNames.push_back("проспект Независимости"); toDo.streetNames.push_back("Московская улица"); - index.ForEachInScale([&toDo](FeatureType & ft) { toDo(ft); }, scales::GetUpperScale()); + dataSource.ForEachInScale([&toDo](FeatureType & ft) { toDo(ft); }, scales::GetUpperScale()); houser.LoadStreets(toDo.GetFeatureIDs()); TEST_GREATER_OR_EQUAL(houser.MergeStreets(), 1, ()); TEST_LESS_OR_EQUAL(houser.MergeStreets(), 5, ()); } { - search::HouseDetector houser(index); + search::HouseDetector houser(dataSource); StreetIDsByName toDo; toDo.streetNames.push_back("проспект Независимости"); toDo.streetNames.push_back("Московская улица"); toDo.streetNames.push_back("Вишнёвый переулок"); toDo.streetNames.push_back("Студенческий переулок"); toDo.streetNames.push_back("Полоцкий переулок"); - index.ForEachInScale([&toDo](FeatureType & ft) { toDo(ft); }, scales::GetUpperScale()); + dataSource.ForEachInScale([&toDo](FeatureType & ft) { toDo(ft); }, scales::GetUpperScale()); houser.LoadStreets(toDo.GetFeatureIDs()); TEST_GREATER_OR_EQUAL(houser.MergeStreets(), 1, ()); TEST_LESS_OR_EQUAL(houser.MergeStreets(), 8, ()); } { - search::HouseDetector houser(index); + search::HouseDetector houser(dataSource); StreetIDsByName toDo; toDo.streetNames.push_back("проспект Независимости"); toDo.streetNames.push_back("Московская улица"); toDo.streetNames.push_back("улица Кирова"); toDo.streetNames.push_back("улица Городской Вал"); - index.ForEachInScale([&toDo](FeatureType & ft) { toDo(ft); }, scales::GetUpperScale()); + dataSource.ForEachInScale([&toDo](FeatureType & ft) { toDo(ft); }, scales::GetUpperScale()); houser.LoadStreets(toDo.GetFeatureIDs()); TEST_GREATER_OR_EQUAL(houser.MergeStreets(), 1, ()); TEST_LESS_OR_EQUAL(houser.MergeStreets(), 10, ()); @@ -257,14 +257,14 @@ UNIT_TEST(HS_StreetsMerge) namespace { -m2::PointD FindHouse(DataSourceBase & index, vector const & streets, +m2::PointD FindHouse(DataSourceBase & dataSource, vector const & streets, string const & houseName, double offset) { - search::HouseDetector houser(index); + search::HouseDetector houser(dataSource); StreetIDsByName toDo; toDo.streetNames = streets; - index.ForEachInScale([&toDo](FeatureType & ft) { toDo(ft); }, scales::GetUpperScale()); + dataSource.ForEachInScale([&toDo](FeatureType & ft) { toDo(ft); }, scales::GetUpperScale()); if (houser.LoadStreets(toDo.GetFeatureIDs()) > 0) TEST_GREATER(houser.MergeStreets(), 0, ()); @@ -284,29 +284,29 @@ UNIT_TEST(HS_FindHouseSmoke) { classificator::Load(); - DataSource index; - auto const p = index.Register(LocalCountryFile::MakeForTesting("minsk-pass")); + DataSource dataSource; + auto const p = dataSource.Register(LocalCountryFile::MakeForTesting("minsk-pass")); TEST(p.first.IsAlive(), ()); TEST_EQUAL(MwmSet::RegResult::Success, p.second, ()); { vector streetName(1, "Московская улица"); - TEST_ALMOST_EQUAL_ULPS(FindHouse(index, streetName, "7", 100), + TEST_ALMOST_EQUAL_ULPS(FindHouse(dataSource, streetName, "7", 100), m2::PointD(27.539850827603416406, 64.222406776416349317), ()); } { vector streetName(1, "проспект Независимости"); - TEST_ALMOST_EQUAL_ULPS(FindHouse(index, streetName, "10", 40), + TEST_ALMOST_EQUAL_ULPS(FindHouse(dataSource, streetName, "10", 40), m2::PointD(27.551428582902474318, 64.234707387050306693), ()); } { vector streetName(1, "улица Ленина"); /// @todo This cases doesn't work, but should in new search algorithms. - //m2::PointD pt = FindHouse(index, streetName, "28", 50); - //m2::PointD pt = FindHouse(index, streetName, "30", 50); + //m2::PointD pt = FindHouse(dataSource, streetName, "28", 50); + //m2::PointD pt = FindHouse(dataSource, streetName, "30", 50); - m2::PointD pt = FindHouse(index, streetName, "21", 50); + m2::PointD pt = FindHouse(dataSource, streetName, "21", 50); TEST_ALMOST_EQUAL_ULPS(pt, m2::PointD(27.56477391395549148, 64.234502198059132638), ()); } } @@ -385,8 +385,8 @@ UNIT_TEST(HS_MWMSearch) return; } - DataSource index; - auto p = index.Register(LocalCountryFile::MakeForTesting(country)); + DataSource dataSource; + auto p = dataSource.Register(LocalCountryFile::MakeForTesting(country)); if (p.second != MwmSet::RegResult::Success) { LOG(LWARNING, ("MWM file not found")); @@ -395,7 +395,7 @@ UNIT_TEST(HS_MWMSearch) TEST(p.first.IsAlive(), ()); CollectStreetIDs streetIDs; - index.ForEachInScale(streetIDs, scales::GetUpperScale()); + dataSource.ForEachInScale(streetIDs, scales::GetUpperScale()); streetIDs.Finish(); string line; @@ -430,7 +430,7 @@ UNIT_TEST(HS_MWMSearch) sort(addresses.begin(), addresses.end()); - search::HouseDetector detector(index); + search::HouseDetector detector(dataSource); size_t all = 0, matched = 0, notMatched = 0; size_t const percent = max(size_t(1), addresses.size() / 100); diff --git a/search/search_tests/locality_finder_test.cpp b/search/search_tests/locality_finder_test.cpp index 3ddbf96396..c187f87cd4 100644 --- a/search/search_tests/locality_finder_test.cpp +++ b/search/search_tests/locality_finder_test.cpp @@ -22,7 +22,7 @@ class LocalityFinderTest : public generator::tests_support::TestWithClassificato { platform::LocalCountryFile m_worldFile; - DataSource m_index; + DataSource m_dataSource; ::base::Cancellable m_cancellable; search::VillagesCache m_villagesCache; @@ -34,14 +34,14 @@ class LocalityFinderTest : public generator::tests_support::TestWithClassificato public: LocalityFinderTest() : m_villagesCache(m_cancellable) - , m_boundariesTable(m_index) - , m_finder(m_index, m_boundariesTable, m_villagesCache) + , m_boundariesTable(m_dataSource) + , m_finder(m_dataSource, m_boundariesTable, m_villagesCache) { m_worldFile = platform::LocalCountryFile::MakeForTesting("World"); try { - auto const p = m_index.Register(m_worldFile); + auto const p = m_dataSource.Register(m_worldFile); TEST_EQUAL(MwmSet::RegResult::Success, p.second, ()); MwmSet::MwmId const & id = p.first; diff --git a/search/search_tests_support/helpers.cpp b/search/search_tests_support/helpers.cpp index d23a7ec9cd..3816f3650e 100644 --- a/search/search_tests_support/helpers.cpp +++ b/search/search_tests_support/helpers.cpp @@ -13,7 +13,7 @@ namespace search { SearchTest::SearchTest() : m_scopedLog(LDEBUG) - , m_engine(m_index, make_unique(), Engine::Params{}) + , m_engine(m_dataSource, make_unique(), Engine::Params{}) { SetViewport(MercatorBounds::FullRect()); } @@ -36,7 +36,7 @@ bool SearchTest::ResultsMatch(string const & query, string const & locale, { tests_support::TestSearchRequest request(m_engine, query, locale, Mode::Everywhere, m_viewport); request.Run(); - return MatchResults(m_index, rules, request.Results()); + return MatchResults(m_dataSource, rules, request.Results()); } bool SearchTest::ResultsMatch(string const & query, Mode mode, @@ -44,12 +44,12 @@ bool SearchTest::ResultsMatch(string const & query, Mode mode, { tests_support::TestSearchRequest request(m_engine, query, "en", mode, m_viewport); request.Run(); - return MatchResults(m_index, rules, request.Results()); + return MatchResults(m_dataSource, rules, request.Results()); } bool SearchTest::ResultsMatch(vector const & results, TRules const & rules) { - return MatchResults(m_index, rules, results); + return MatchResults(m_dataSource, rules, results); } bool SearchTest::ResultsMatch(SearchParams const & params, TRules const & rules) @@ -61,7 +61,7 @@ bool SearchTest::ResultsMatch(SearchParams const & params, TRules const & rules) bool SearchTest::ResultMatches(search::Result const & result, TRule const & rule) { - return tests_support::ResultMatches(m_index, rule, result); + return tests_support::ResultMatches(m_dataSource, rule, result); } unique_ptr SearchTest::MakeRequest( @@ -84,7 +84,7 @@ size_t SearchTest::CountFeatures(m2::RectD const & rect) { size_t count = 0; auto counter = [&count](const FeatureType & /* ft */) { ++count; }; - m_index.ForEachInRect(counter, rect, scales::GetUpperScale()); + m_dataSource.ForEachInRect(counter, rect, scales::GetUpperScale()); return count; } diff --git a/search/search_tests_support/test_results_matching.cpp b/search/search_tests_support/test_results_matching.cpp index ede4170315..381f18f876 100644 --- a/search/search_tests_support/test_results_matching.cpp +++ b/search/search_tests_support/test_results_matching.cpp @@ -62,7 +62,7 @@ string AlternativesMatchingRule::ToString() const return os.str(); } -bool MatchResults(DataSourceBase const & index, vector> rules, +bool MatchResults(DataSourceBase const & dataSource, vector> rules, vector const & actual) { vector resultIds; @@ -83,7 +83,7 @@ bool MatchResults(DataSourceBase const & index, vector> } unexpected.push_back(DebugPrint(feature) + " from " + DebugPrint(feature.GetID().m_mwmId)); }; - index.ReadFeatures(removeMatched, resultIds); + dataSource.ReadFeatures(removeMatched, resultIds); if (rules.empty() && unexpected.empty()) return true; @@ -100,18 +100,18 @@ bool MatchResults(DataSourceBase const & index, vector> return false; } -bool MatchResults(DataSourceBase const & index, vector> rules, +bool MatchResults(DataSourceBase const & dataSource, vector> rules, search::Results const & actual) { vector const results(actual.begin(), actual.end()); - return MatchResults(index, rules, results); + return MatchResults(dataSource, rules, results); } -bool ResultMatches(DataSourceBase const & index, shared_ptr rule, +bool ResultMatches(DataSourceBase const & dataSource, shared_ptr rule, search::Result const & result) { bool matches = false; - index.ReadFeature([&](FeatureType const & ft) { matches = rule->Matches(ft); }, result.GetFeatureID()); + dataSource.ReadFeature([&](FeatureType const & ft) { matches = rule->Matches(ft); }, result.GetFeatureID()); return matches; } diff --git a/search/search_tests_support/test_results_matching.hpp b/search/search_tests_support/test_results_matching.hpp index 5407976a69..f6d6fd72d5 100644 --- a/search/search_tests_support/test_results_matching.hpp +++ b/search/search_tests_support/test_results_matching.hpp @@ -74,11 +74,11 @@ std::shared_ptr AlternativesMatch(TArgs &&... args) return std::make_shared(std::forward(args)...); } -bool MatchResults(DataSourceBase const & index, std::vector> rules, +bool MatchResults(DataSourceBase const & dataSource, std::vector> rules, std::vector const & actual); -bool MatchResults(DataSourceBase const & index, std::vector> rules, +bool MatchResults(DataSourceBase const & dataSource, std::vector> rules, search::Results const & actual); -bool ResultMatches(DataSourceBase const & index, std::shared_ptr rule, +bool ResultMatches(DataSourceBase const & dataSource, std::shared_ptr rule, search::Result const & result); std::string DebugPrint(MatchingRule const & rule); diff --git a/search/search_tests_support/test_search_engine.cpp b/search/search_tests_support/test_search_engine.cpp index bd00d321ce..a9c8dffff2 100644 --- a/search/search_tests_support/test_search_engine.cpp +++ b/search/search_tests_support/test_search_engine.cpp @@ -12,15 +12,15 @@ namespace search { namespace tests_support { -TestSearchEngine::TestSearchEngine(DataSourceBase & index, unique_ptr infoGetter, +TestSearchEngine::TestSearchEngine(DataSourceBase & dataSource, unique_ptr infoGetter, Engine::Params const & params) - : m_infoGetter(move(infoGetter)), m_engine(index, GetDefaultCategories(), *m_infoGetter, params) + : m_infoGetter(move(infoGetter)), m_engine(dataSource, GetDefaultCategories(), *m_infoGetter, params) { } -TestSearchEngine::TestSearchEngine(DataSourceBase & index, Engine::Params const & params) +TestSearchEngine::TestSearchEngine(DataSourceBase & dataSource, Engine::Params const & params) : m_infoGetter(storage::CountryInfoReader::CreateCountryInfoReader(GetPlatform())) - , m_engine(index, GetDefaultCategories(), *m_infoGetter, params) + , m_engine(dataSource, GetDefaultCategories(), *m_infoGetter, params) { } diff --git a/search/search_tests_support/test_search_engine.hpp b/search/search_tests_support/test_search_engine.hpp index c73d85698e..bc51c33bac 100644 --- a/search/search_tests_support/test_search_engine.hpp +++ b/search/search_tests_support/test_search_engine.hpp @@ -18,9 +18,9 @@ namespace tests_support class TestSearchEngine { public: - TestSearchEngine(DataSourceBase & index, std::unique_ptr infoGetter, + TestSearchEngine(DataSourceBase & dataSource, std::unique_ptr infoGetter, Engine::Params const & params); - TestSearchEngine(DataSourceBase & index, Engine::Params const & params); + TestSearchEngine(DataSourceBase & dataSource, Engine::Params const & params); void SetLocale(std::string const & locale) { m_engine.SetLocale(locale); } diff --git a/search/search_tests_support/test_with_custom_mwms.hpp b/search/search_tests_support/test_with_custom_mwms.hpp index ccbf30606b..606ea08b2e 100644 --- a/search/search_tests_support/test_with_custom_mwms.hpp +++ b/search/search_tests_support/test_with_custom_mwms.hpp @@ -23,7 +23,7 @@ class TestWithCustomMwms : public generator::tests_support::TestWithCustomMwms public: TestWithCustomMwms() { - editor::tests_support::SetUpEditorForTesting(my::make_unique(m_index)); + editor::tests_support::SetUpEditorForTesting(my::make_unique(m_dataSource)); } ~TestWithCustomMwms() override { editor::tests_support::TearDownEditorForTesting(); } @@ -31,7 +31,7 @@ public: template void EditFeature(FeatureID const & id, EditorFn && fn) { - EditableDataSource::FeaturesLoaderGuard loader(m_index, id.m_mwmId); + EditableDataSource::FeaturesLoaderGuard loader(m_dataSource, id.m_mwmId); FeatureType ft; CHECK(loader.GetFeatureByIndex(id.m_index, ft), ()); editor::tests_support::EditFeature(ft, std::forward(fn)); diff --git a/search/utils.cpp b/search/utils.cpp index b8d6867a34..9dca350b72 100644 --- a/search/utils.cpp +++ b/search/utils.cpp @@ -42,24 +42,24 @@ strings::LevenshteinDFA BuildLevenshteinDFA(strings::UniString const & s) return strings::LevenshteinDFA(s, 1 /* prefixSize */, kAllowedMisprints, GetMaxErrorsForToken(s)); } -MwmSet::MwmHandle FindWorld(DataSourceBase const & index, vector> const & infos) +MwmSet::MwmHandle FindWorld(DataSourceBase const & dataSource, vector> const & infos) { MwmSet::MwmHandle handle; for (auto const & info : infos) { if (info->GetType() == MwmInfo::WORLD) { - handle = index.GetMwmHandleById(MwmSet::MwmId(info)); + handle = dataSource.GetMwmHandleById(MwmSet::MwmId(info)); break; } } return handle; } -MwmSet::MwmHandle FindWorld(DataSourceBase const & index) +MwmSet::MwmHandle FindWorld(DataSourceBase const & dataSource) { vector> infos; - index.GetMwmsInfo(infos); - return FindWorld(index, infos); + dataSource.GetMwmsInfo(infos); + return FindWorld(dataSource, infos); } } // namespace search diff --git a/search/utils.hpp b/search/utils.hpp index 70fd5e4e8c..c36ef22f8d 100644 --- a/search/utils.hpp +++ b/search/utils.hpp @@ -114,7 +114,7 @@ bool FillCategories(QuerySliceOnRawStrings const & slice, Locales const & loc return !types.empty(); } -MwmSet::MwmHandle FindWorld(DataSourceBase const &index, +MwmSet::MwmHandle FindWorld(DataSourceBase const & dataSource, std::vector> const &infos); -MwmSet::MwmHandle FindWorld(DataSourceBase const & index); +MwmSet::MwmHandle FindWorld(DataSourceBase const & dataSource); } // namespace search diff --git a/track_analyzing/track_matcher.cpp b/track_analyzing/track_matcher.cpp index f9d708504b..dffa3c2fcb 100644 --- a/track_analyzing/track_matcher.cpp +++ b/track_analyzing/track_matcher.cpp @@ -59,14 +59,14 @@ TrackMatcher::TrackMatcher(storage::Storage const & storage, NumMwmId mwmId, { auto localCountryFile = storage.GetLatestLocalFile(countryFile); CHECK(localCountryFile, ("Can't find latest country file for", countryFile.GetName())); - auto registerResult = m_index.Register(*localCountryFile); + auto registerResult = m_dataSource.Register(*localCountryFile); CHECK_EQUAL(registerResult.second, MwmSet::RegResult::Success, ("Can't register mwm", countryFile.GetName())); - MwmSet::MwmHandle const handle = m_index.GetMwmHandleByCountryFile(countryFile); + MwmSet::MwmHandle const handle = m_dataSource.GetMwmHandleByCountryFile(countryFile); m_graph = make_unique( make_shared( - GeometryLoader::Create(m_index, handle, m_vehicleModel, false /* loadAltitudes */)), + GeometryLoader::Create(m_dataSource, handle, m_vehicleModel, false /* loadAltitudes */)), EdgeEstimator::Create(VehicleType::Car, *m_vehicleModel, nullptr /* trafficStash */)); DeserializeIndexGraph(*handle.GetValue(), VehicleType::Car, *m_graph); @@ -85,7 +85,7 @@ void TrackMatcher::MatchTrack(vector const & track, vector m_vehicleModel; std::unique_ptr m_graph; uint64_t m_tracksCount = 0; diff --git a/ugc/api.cpp b/ugc/api.cpp index 6125d57065..0ee32a2881 100644 --- a/ugc/api.cpp +++ b/ugc/api.cpp @@ -9,8 +9,8 @@ using namespace ugc; namespace ugc { -Api::Api(DataSourceBase const & index, NumberOfUnsynchronizedCallback const & callback) - : m_storage(index), m_loader(index) +Api::Api(DataSourceBase const & dataSource, NumberOfUnsynchronizedCallback const & callback) + : m_storage(dataSource), m_loader(dataSource) { m_thread.Push([this, callback] { m_storage.Load(); diff --git a/ugc/api.hpp b/ugc/api.hpp index 7e28295226..40198c076c 100644 --- a/ugc/api.hpp +++ b/ugc/api.hpp @@ -24,7 +24,7 @@ public: using OnResultCallback = platform::SafeCallback; using NumberOfUnsynchronizedCallback = std::function; - Api(DataSourceBase const & index, NumberOfUnsynchronizedCallback const & callback); + Api(DataSourceBase const & dataSource, NumberOfUnsynchronizedCallback const & callback); void GetUGC(FeatureID const & id, UGCCallbackUnsafe const & callback); void SetUGCUpdate(FeatureID const & id, UGCUpdate const & ugc, diff --git a/ugc/loader.cpp b/ugc/loader.cpp index b6a4fc2c4a..3c2ad20085 100644 --- a/ugc/loader.cpp +++ b/ugc/loader.cpp @@ -7,11 +7,11 @@ namespace ugc { -Loader::Loader(DataSourceBase const & index) : m_index(index) {} +Loader::Loader(DataSourceBase const & dataSource) : m_dataSource(dataSource) {} UGC Loader::GetUGC(FeatureID const & featureId) { - auto const handle = m_index.GetMwmHandleById(featureId.m_mwmId); + auto const handle = m_dataSource.GetMwmHandleById(featureId.m_mwmId); if (!handle.IsAlive()) return {}; diff --git a/ugc/loader.hpp b/ugc/loader.hpp index 6af167f0a6..8a5fa3b65b 100644 --- a/ugc/loader.hpp +++ b/ugc/loader.hpp @@ -18,7 +18,7 @@ namespace ugc class Loader { public: - Loader(DataSourceBase const & index); + Loader(DataSourceBase const & dataSource); UGC GetUGC(FeatureID const & featureId); private: @@ -30,7 +30,7 @@ private: using EntryPtr = std::shared_ptr; - DataSourceBase const & m_index; + DataSourceBase const & m_dataSource; std::map m_deserializers; std::mutex m_mutex; }; diff --git a/ugc/storage.cpp b/ugc/storage.cpp index 927f34e85a..9909b145c5 100644 --- a/ugc/storage.cpp +++ b/ugc/storage.cpp @@ -443,7 +443,7 @@ uint64_t Storage::UGCSizeAtIndex(size_t const indexPosition) const unique_ptr Storage::GetFeature(FeatureID const & id) const { CHECK(id.IsValid(), ()); - EditableDataSource::FeaturesLoaderGuard guard(m_index, id.m_mwmId); + EditableDataSource::FeaturesLoaderGuard guard(m_dataSource, id.m_mwmId); auto feature = guard.GetOriginalOrEditedFeatureByIndex(id.m_index); feature->ParseGeometry(FeatureType::BEST_GEOMETRY); if (feature->GetFeatureType() == feature::EGeomType::GEOM_AREA) diff --git a/ugc/storage.hpp b/ugc/storage.hpp index 9f1b2c337d..bc14492eed 100644 --- a/ugc/storage.hpp +++ b/ugc/storage.hpp @@ -16,7 +16,7 @@ namespace ugc class Storage { public: - explicit Storage(DataSourceBase const & index) : m_index(index) {} + explicit Storage(DataSourceBase const & dataSource) : m_dataSource(dataSource) {} UGCUpdate GetUGCUpdate(FeatureID const & id) const; @@ -46,7 +46,7 @@ private: std::unique_ptr GetFeature(FeatureID const & id) const; void Migrate(std::string const & indexFilePath); - DataSourceBase const & m_index; + DataSourceBase const & m_dataSource; UpdateIndexes m_indexes; size_t m_numberOfDeleted = 0; }; diff --git a/ugc/ugc_tests/storage_tests.cpp b/ugc/ugc_tests/storage_tests.cpp index 13ac9a384a..da2815e5ae 100644 --- a/ugc/ugc_tests/storage_tests.cpp +++ b/ugc/ugc_tests/storage_tests.cpp @@ -102,7 +102,7 @@ public: return FeatureIdForPoint(mercator, ftypes::IsRailwayStationChecker::Instance()); } - DataSourceBase & GetIndex() { return m_index; } + DataSourceBase & GetDataSource() { return m_dataSource; } ~MwmBuilder() { @@ -129,7 +129,7 @@ private: fn(builder); } - auto result = m_index.RegisterMap(m_testMwm); + auto result = m_dataSource.RegisterMap(m_testMwm); CHECK_EQUAL(result.second, MwmSet::RegResult::Success, ()); auto const & id = result.first; @@ -152,19 +152,19 @@ private: if (checker(featureType)) id = featureType.GetID(); }; - m_index.ForEachInRect(fn, rect, scales::GetUpperScale()); + m_dataSource.ForEachInRect(fn, rect, scales::GetUpperScale()); CHECK(id.IsValid(), ()); return id; } void Cleanup(platform::LocalCountryFile const & map) { - m_index.DeregisterMap(map.GetCountryFile()); + m_dataSource.DeregisterMap(map.GetCountryFile()); platform::CountryIndexes::DeleteFromDisk(map); map.DeleteFromDisk(MapOptions::Map); } - DataSource m_index; + DataSource m_dataSource; storage::CountryInfoGetterForTesting m_infoGetter; platform::LocalCountryFile m_testMwm; }; @@ -188,7 +188,7 @@ UNIT_CLASS_TEST(StorageTest, Smoke) builder.Build({TestCafe(point)}); auto const id = builder.FeatureIdForCafeAtPoint(point); auto const original = MakeTestUGCUpdate(Time(chrono::hours(24 * 300))); - Storage storage(builder.GetIndex()); + Storage storage(builder.GetDataSource()); storage.Load(); TEST_EQUAL(storage.SetUGCUpdate(id, original), Storage::SettingResult::Success, ()); auto const actual = storage.GetUGCUpdate(id); @@ -210,7 +210,7 @@ UNIT_CLASS_TEST(StorageTest, DuplicatesAndDefragmentationSmoke) auto const second = MakeTestUGCUpdate(Time(chrono::hours(24 * 100))); auto const third = MakeTestUGCUpdate(Time(chrono::hours(24 * 300))); auto const last = MakeTestUGCUpdate(Time(chrono::hours(24 * 100))); - Storage storage(builder.GetIndex()); + Storage storage(builder.GetDataSource()); storage.Load(); TEST_EQUAL(storage.SetUGCUpdate(cafeId, first), Storage::SettingResult::Success, ()); TEST_EQUAL(storage.SetUGCUpdate(cafeId, second), Storage::SettingResult::Success, ()); @@ -236,7 +236,7 @@ UNIT_CLASS_TEST(StorageTest, DifferentTypes) auto const railwayId = builder.FeatureIdForRailwayAtPoint(point); auto const cafeUGC = MakeTestUGCUpdate(Time(chrono::hours(24 * 10))); auto const railwayUGC = MakeTestUGCUpdate(Time(chrono::hours(24 * 300))); - Storage storage(builder.GetIndex()); + Storage storage(builder.GetDataSource()); storage.Load(); TEST_EQUAL(storage.SetUGCUpdate(cafeId, cafeUGC), Storage::SettingResult::Success, ()); TEST_EQUAL(storage.SetUGCUpdate(railwayId, railwayUGC), Storage::SettingResult::Success, ()); @@ -256,14 +256,14 @@ UNIT_CLASS_TEST(StorageTest, LoadIndex) auto const railwayUGC = MakeTestUGCUpdate(Time(chrono::hours(24 * 300))); { - Storage storage(builder.GetIndex()); + Storage storage(builder.GetDataSource()); storage.Load(); TEST_EQUAL(storage.SetUGCUpdate(cafeId, cafeUGC), Storage::SettingResult::Success, ()); TEST_EQUAL(storage.SetUGCUpdate(railwayId, railwayUGC), Storage::SettingResult::Success, ()); storage.SaveIndex(); } - Storage storage(builder.GetIndex()); + Storage storage(builder.GetDataSource()); storage.Load(); auto const & indexArray = storage.GetIndexesForTesting(); TEST_EQUAL(indexArray.size(), 2, ()); @@ -286,7 +286,7 @@ UNIT_CLASS_TEST(StorageTest, ContentTest) auto const cafeId = builder.FeatureIdForCafeAtPoint(cafePoint); auto const oldUGC = MakeTestUGCUpdate(Time(chrono::hours(24 * 10))); auto const newUGC = MakeTestUGCUpdate(Time(chrono::hours(24 * 300))); - Storage storage(builder.GetIndex()); + Storage storage(builder.GetDataSource()); storage.Load(); TEST_EQUAL(storage.SetUGCUpdate(cafeId, oldUGC), Storage::SettingResult::Success, ()); TEST_EQUAL(storage.SetUGCUpdate(cafeId, newUGC), Storage::SettingResult::Success, ()); @@ -338,7 +338,7 @@ UNIT_CLASS_TEST(StorageTest, InvalidUGC) m2::PointD const cafePoint(1.0, 1.0); builder.Build({TestCafe(cafePoint)}); auto const cafeId = builder.FeatureIdForCafeAtPoint(cafePoint); - Storage storage(builder.GetIndex()); + Storage storage(builder.GetDataSource()); storage.Load(); UGCUpdate first; @@ -364,7 +364,7 @@ UNIT_CLASS_TEST(StorageTest, DifferentUGCVersions) m2::PointD const secondPoint(2.0, 2.0); builder.Build({TestCafe(firstPoint), TestCafe(secondPoint)}); - Storage storage(builder.GetIndex()); + Storage storage(builder.GetDataSource()); storage.Load(); auto const firstId = builder.FeatureIdForCafeAtPoint(firstPoint); @@ -389,13 +389,13 @@ UNIT_CLASS_TEST(StorageTest, NumberOfUnsynchronized) auto const cafeUGC = MakeTestUGCUpdate(Time(chrono::hours(24 * 10))); { - Storage storage(builder.GetIndex()); + Storage storage(builder.GetDataSource()); storage.Load(); TEST_EQUAL(storage.SetUGCUpdate(cafeId, cafeUGC), Storage::SettingResult::Success, ()); storage.SaveIndex(); } - Storage storage(builder.GetIndex()); + Storage storage(builder.GetDataSource()); storage.Load(); TEST_EQUAL(storage.GetNumberOfUnsynchronized(), 1, ()); @@ -419,7 +419,7 @@ UNIT_CLASS_TEST(StorageTest, GetNumberOfUnsentSeparately) auto const cafeUGC = MakeTestUGCUpdate(Time(chrono::hours(24 * 10))); { - Storage storage(builder.GetIndex()); + Storage storage(builder.GetDataSource()); storage.Load(); TEST_EQUAL(storage.SetUGCUpdate(cafeId, cafeUGC), Storage::SettingResult::Success, ()); storage.SaveIndex(); @@ -429,7 +429,7 @@ UNIT_CLASS_TEST(StorageTest, GetNumberOfUnsentSeparately) TEST_EQUAL(lightweight::GetNumberOfUnsentUGC(), 1, ()); { - Storage storage(builder.GetIndex()); + Storage storage(builder.GetDataSource()); storage.Load(); storage.MarkAllAsSynchronized(); TEST_EQUAL(storage.GetNumberOfUnsynchronized(), 0, ()); @@ -463,7 +463,7 @@ UNIT_TEST(UGC_IndexMigrationFromV0ToV1Smoke) builder.Build({}); auto const v0IndexFilePath = indexFilePath + "." + version; - Storage s(builder.GetIndex()); + Storage s(builder.GetDataSource()); s.LoadForTesting(indexFilePath); uint64_t migratedIndexFileSize = 0; uint64_t v0IndexFileSize = 0; diff --git a/xcode/indexer/indexer.xcodeproj/project.pbxproj b/xcode/indexer/indexer.xcodeproj/project.pbxproj index db941cbd7b..6208abc9b5 100644 --- a/xcode/indexer/indexer.xcodeproj/project.pbxproj +++ b/xcode/indexer/indexer.xcodeproj/project.pbxproj @@ -99,7 +99,7 @@ 670BAA971D0B06E1000302DA /* checker_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 670C60FC1AB065B100C38A8C /* checker_test.cpp */; }; 670BAA981D0B06E1000302DA /* features_offsets_table_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 670C60FD1AB065B100C38A8C /* features_offsets_table_test.cpp */; }; 670BAA9B1D0B06E1000302DA /* index_builder_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 670C61001AB065B100C38A8C /* index_builder_test.cpp */; }; - 670BAA9C1D0B06E1000302DA /* index_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 670C61011AB065B100C38A8C /* index_test.cpp */; }; + 670BAA9C1D0B06E1000302DA /* data_source_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 670C61011AB065B100C38A8C /* data_source_test.cpp */; }; 670BAA9D1D0B06E1000302DA /* interval_index_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 670C61021AB065B100C38A8C /* interval_index_test.cpp */; }; 670BAA9E1D0B06E1000302DA /* mwm_set_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 670C61041AB065B100C38A8C /* mwm_set_test.cpp */; }; 670BAAA01D0B06E1000302DA /* scales_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 670C61061AB065B100C38A8C /* scales_test.cpp */; }; @@ -336,7 +336,7 @@ 670C60FC1AB065B100C38A8C /* checker_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = checker_test.cpp; sourceTree = ""; }; 670C60FD1AB065B100C38A8C /* features_offsets_table_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = features_offsets_table_test.cpp; sourceTree = ""; }; 670C61001AB065B100C38A8C /* index_builder_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = index_builder_test.cpp; sourceTree = ""; }; - 670C61011AB065B100C38A8C /* index_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = index_test.cpp; sourceTree = ""; }; + 670C61011AB065B100C38A8C /* data_source_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = data_source_test.cpp; sourceTree = ""; }; 670C61021AB065B100C38A8C /* interval_index_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = interval_index_test.cpp; sourceTree = ""; }; 670C61041AB065B100C38A8C /* mwm_set_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = mwm_set_test.cpp; sourceTree = ""; }; 670C61061AB065B100C38A8C /* scales_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = scales_test.cpp; sourceTree = ""; }; @@ -569,7 +569,7 @@ 670C60FD1AB065B100C38A8C /* features_offsets_table_test.cpp */, 3D489BA81D3D1F8A0052AA38 /* features_vector_test.cpp */, 670C61001AB065B100C38A8C /* index_builder_test.cpp */, - 670C61011AB065B100C38A8C /* index_test.cpp */, + 670C61011AB065B100C38A8C /* data_source_test.cpp */, 670C61021AB065B100C38A8C /* interval_index_test.cpp */, 40A1C309202B321000F71672 /* locality_index_test.cpp */, 670C61041AB065B100C38A8C /* mwm_set_test.cpp */, @@ -968,7 +968,7 @@ 670BAA911D0B06B4000302DA /* categories_test.cpp in Sources */, 3D489BC81D3D22190052AA38 /* string_slice_tests.cpp in Sources */, 670BAAA11D0B06E1000302DA /* sort_and_merge_intervals_test.cpp in Sources */, - 670BAA9C1D0B06E1000302DA /* index_test.cpp in Sources */, + 670BAA9C1D0B06E1000302DA /* data_source_test.cpp in Sources */, 670BAA9B1D0B06E1000302DA /* index_builder_test.cpp in Sources */, 670C612C1AB0663400C38A8C /* testingmain.cpp in Sources */, 3D489BC61D3D220F0052AA38 /* editable_map_object_test.cpp in Sources */,