[indexer] Test features retrieval from expected zoom level.

This commit is contained in:
tatiana-yan 2019-03-22 13:59:21 +03:00 committed by mpimenov
parent f0f5e2bf79
commit 876d639b38
3 changed files with 33 additions and 6 deletions

View file

@ -313,6 +313,14 @@ string TestPOI::ToDebugString() const
return os.str();
}
feature::TypesHolder TestPOI::GetTypes() const
{
feature::TypesHolder types;
for (auto const path : m_types)
types.Add(classif().GetTypeByPath(path));
return types;
}
// TestMultilingualPOI -----------------------------------------------------------------------------
TestMultilingualPOI::TestMultilingualPOI(m2::PointD const & center, string const & defaultName,
map<string, string> const & multilingualNames)

View file

@ -1,5 +1,6 @@
#pragma once
#include "indexer/feature_data.hpp"
#include "indexer/feature_decl.hpp"
#include "indexer/feature_meta.hpp"
#include "indexer/mwm_set.hpp"
@ -156,6 +157,7 @@ public:
void Serialize(FeatureBuilder1 & fb) const override;
std::string ToDebugString() const override;
feature::TypesHolder GetTypes() const;
void SetHouseNumber(std::string const & houseNumber) { m_houseNumber = houseNumber; }
void SetStreetName(std::string const & name) { m_streetName = name; }
void SetTypes(std::vector<std::vector<std::string>> const & types) { m_types = types; }

View file

@ -10,6 +10,7 @@
#include "indexer/data_source.hpp"
#include "indexer/feature.hpp"
#include "indexer/feature_covering.hpp"
#include "indexer/feature_visibility.hpp"
#include "indexer/mwm_set.hpp"
#include "indexer/scale_index.hpp"
@ -42,16 +43,17 @@ class ScaleIndexReadingTest : public TestWithCustomMwms
{
public:
template <typename ScaleIndex>
Names CollectNames(MwmSet::MwmId const & id, ScaleIndex const & index, int scale,
m2::RectD const & rect)
Names CollectNames(MwmSet::MwmId const & id, ScaleIndex const & index, int scaleForIntervals,
int scaleForZoomLevels, m2::RectD const & rect)
{
covering::CoveringGetter covering(rect, covering::ViewportWithLowLevels);
vector<uint32_t> indices;
for (auto const & interval : covering.Get<RectId::DEPTH_LEVELS>(scale))
for (auto const & interval : covering.Get<RectId::DEPTH_LEVELS>(scaleForIntervals))
{
index.ForEachInIntervalAndScale(interval.first, interval.second, scale,
[&](uint64_t /* key */, uint32_t value) { indices.push_back(value); });
index.ForEachInIntervalAndScale(
interval.first, interval.second, scaleForZoomLevels,
[&](uint64_t /* key */, uint32_t value) { indices.push_back(value); });
}
FeaturesLoaderGuard loader(m_dataSource, id);
@ -105,11 +107,26 @@ UNIT_CLASS_TEST(ScaleIndexReadingTest, Mmap)
ScaleIndex<ReaderPtr<Reader>> index(subReader, factory);
auto collectNames = [&](m2::RectD const & rect) {
return CollectNames(id, index, header.GetLastScale(), rect);
return CollectNames(id, index, header.GetLastScale(), header.GetLastScale(), rect);
};
TEST_EQUAL(collectNames(m2::RectD{-0.5, -0.5, 0.5, 0.5}), Names({"A"}), ());
TEST_EQUAL(collectNames(m2::RectD{0.5, -0.5, 1.5, 1.5}), Names({"B", "C"}), ());
TEST_EQUAL(collectNames(m2::RectD{-0.5, -0.5, 1.5, 1.5}), Names({"A", "B", "C", "D"}), ());
auto collectNamesForExactScale = [&](m2::RectD const & rect, int scale) {
return CollectNames(id, index, header.GetLastScale(), scale, rect);
};
auto const drawableScale = feature::GetMinDrawableScaleClassifOnly(a.GetTypes());
CHECK_LESS(drawableScale, header.GetLastScale(),
("Change the test to ensure scales less than last scale work."));
TEST_EQUAL(collectNamesForExactScale(m2::RectD{-0.5, -0.5, 0.5, 0.5}, drawableScale),
Names({"A"}), ());
TEST_EQUAL(collectNamesForExactScale(m2::RectD{0.5, -0.5, 1.5, 1.5}, drawableScale),
Names({"B", "C"}), ());
TEST_EQUAL(collectNamesForExactScale(m2::RectD{-0.5, -0.5, 1.5, 1.5}, drawableScale),
Names({"A", "B", "C", "D"}), ());
}
} // namespace