Files
comaps/storage/storage_integration_tests/lightweight_matching_tests.cpp
Konstantin Pastbin e3e4a1985a Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run:
  git remote add om-historic [om-historic.git repo url]
  git fetch --tags om-historic
  git replace squashed-history historic-commits
2025-05-08 21:10:51 +07:00

52 lines
1.3 KiB
C++

#include "testing/testing.hpp"
#include "storage/country_info_reader_light.hpp"
#include "storage/storage_defines.hpp"
#include "geometry/mercator.hpp"
#include "geometry/point2d.hpp"
#include <utility>
#include <vector>
namespace lightweight_matching_tests
{
double constexpr kStepInMercator = 1;
struct PointAndCountry
{
PointAndCountry(m2::PointD && pt, storage::CountryId && country)
: m_pt(std::move(pt)), m_country(std::move(country))
{
}
m2::PointD m_pt;
storage::CountryId m_country;
};
using lightweight::CountryInfoReader;
UNIT_CLASS_TEST(CountryInfoReader, LightweightMatching)
{
auto const reader = storage::CountryInfoReader::CreateCountryInfoReader(GetPlatform());
LOG(LINFO, ("Generating dataset..."));
std::vector<PointAndCountry> dataset;
for (auto x = mercator::Bounds::kMinX; x <= mercator::Bounds::kMaxX; x += kStepInMercator)
{
for (auto y = mercator::Bounds::kMinY; y <= mercator::Bounds::kMaxY; y += kStepInMercator)
{
m2::PointD pt(x, y);
dataset.emplace_back(std::move(pt), reader->GetRegionCountryId(pt));
}
}
LOG(LINFO, ("The dataset is generated. Dataset size:", dataset.size()));
for (auto const & sample : dataset)
{
TEST_EQUAL(GetRegionCountryId(sample.m_pt), sample.m_country, (sample.m_pt));
}
}
} // namespace lightweight_matching_tests