Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--generator/cities_boundaries_builder.cpp11
-rw-r--r--generator/generator_tests_support/test_feature.cpp12
-rw-r--r--generator/generator_tests_support/test_feature.hpp5
-rw-r--r--geometry/calipers_box.hpp2
-rw-r--r--geometry/diamond_box.hpp6
-rw-r--r--indexer/cities_boundaries_serdes.hpp1
-rw-r--r--search/cities_boundaries_table.cpp4
-rw-r--r--search/cities_boundaries_table.hpp4
-rw-r--r--search/search_integration_tests/generate_tests.cpp50
9 files changed, 57 insertions, 38 deletions
diff --git a/generator/cities_boundaries_builder.cpp b/generator/cities_boundaries_builder.cpp
index 84922c20d3..d60f73a9fe 100644
--- a/generator/cities_boundaries_builder.cpp
+++ b/generator/cities_boundaries_builder.cpp
@@ -17,10 +17,13 @@
#include "base/assert.hpp"
#include "base/checked_cast.hpp"
+#include "base/logging.hpp"
+#include "base/stl_add.hpp"
#include "base/string_utils.hpp"
-#include <cstdint>
#include <map>
+#include <memory>
+#include <utility>
#include <vector>
#include "defines.hpp"
@@ -115,11 +118,11 @@ bool BuildCitiesBoundaries(string const & dataPath, string const & osmToFeatureP
LOG(LERROR, ("Can't parse feature id to osm id mapping."));
return {};
}
- return make_unique<Mapping>(move(mapping));
+ return my::make_unique<Mapping>(move(mapping));
});
}
-bool BuildCitiesBoundariesForTesting(std::string const & dataPath, TestIdToBoundariesTable & table)
+bool BuildCitiesBoundariesForTesting(string const & dataPath, TestIdToBoundariesTable & table)
{
using Mapping = map<uint32_t, vector<uint64_t>>;
@@ -130,7 +133,7 @@ bool BuildCitiesBoundariesForTesting(std::string const & dataPath, TestIdToBound
LOG(LERROR, ("Can't parse feature id to test id mapping."));
return {};
}
- return make_unique<Mapping>(move(mapping));
+ return my::make_unique<Mapping>(move(mapping));
});
}
} // namespace generator
diff --git a/generator/generator_tests_support/test_feature.cpp b/generator/generator_tests_support/test_feature.cpp
index 169ec5e82e..05b6cbf782 100644
--- a/generator/generator_tests_support/test_feature.cpp
+++ b/generator/generator_tests_support/test_feature.cpp
@@ -15,6 +15,7 @@
#include "coding/multilang_utf8_string.hpp"
#include "base/assert.hpp"
+#include "base/stl_add.hpp"
#include "base/string_utils.hpp"
#include <atomic>
@@ -46,10 +47,11 @@ TestFeature::TestFeature(m2::PointD const & center, string const & name, string
{
}
-TestFeature::TestFeature(vector<m2::PointD> const & area, string const & name, string const & lang)
- : m_id(GenUniqueId()), m_area(area), m_type(Type::Area), m_name(name), m_lang(lang)
+TestFeature::TestFeature(vector<m2::PointD> const & boundary, string const & name,
+ string const & lang)
+ : m_id(GenUniqueId()), m_boundary(boundary), m_type(Type::Area), m_name(name), m_lang(lang)
{
- ASSERT(!m_area.empty(), ());
+ ASSERT(!m_boundary.empty(), ());
}
bool TestFeature::Matches(FeatureType const & feature) const
@@ -74,8 +76,8 @@ void TestFeature::Serialize(FeatureBuilder1 & fb) const
}
case Type::Area:
{
- ASSERT(!m_area.empty(), ());
- for (auto const & p : m_area)
+ ASSERT(!m_boundary.empty(), ());
+ for (auto const & p : m_boundary)
fb.AddPoint(p);
fb.SetArea();
break;
diff --git a/generator/generator_tests_support/test_feature.hpp b/generator/generator_tests_support/test_feature.hpp
index f909b0e731..23df5befed 100644
--- a/generator/generator_tests_support/test_feature.hpp
+++ b/generator/generator_tests_support/test_feature.hpp
@@ -5,6 +5,7 @@
#include "geometry/point2d.hpp"
+#include <cstdint>
#include <string>
#include <utility>
#include <vector>
@@ -44,12 +45,12 @@ protected:
TestFeature(std::string const & name, std::string const & lang);
TestFeature(m2::PointD const & center, std::string const & name, std::string const & lang);
- TestFeature(vector<m2::PointD> const & area, std::string const & name,
+ TestFeature(vector<m2::PointD> const & boundary, std::string const & name,
std::string const & lang);
uint64_t const m_id;
m2::PointD const m_center;
- vector<m2::PointD> const m_area;
+ vector<m2::PointD> const m_boundary;
Type const m_type;
std::string const m_name;
std::string const m_lang;
diff --git a/geometry/calipers_box.hpp b/geometry/calipers_box.hpp
index 61dccff44f..ed49431d88 100644
--- a/geometry/calipers_box.hpp
+++ b/geometry/calipers_box.hpp
@@ -27,7 +27,7 @@ public:
std::vector<PointD> const & Points() const { return m_points; }
- bool HasPoint(PointD const & p) const { return HasPoint(p, kEps /* eps */); }
+ bool HasPoint(PointD const & p) const { return HasPoint(p, kEps); }
bool HasPoint(double x, double y) const { return HasPoint(m2::PointD(x, y)); }
bool HasPoint(PointD const & p, double eps) const;
diff --git a/geometry/diamond_box.hpp b/geometry/diamond_box.hpp
index 6c9b3cdf48..544353208b 100644
--- a/geometry/diamond_box.hpp
+++ b/geometry/diamond_box.hpp
@@ -24,7 +24,11 @@ public:
bool HasPoint(double x, double y) const { return m_box.HasPoint(x + y, x - y); }
bool HasPoint(PointD const & p, double eps) const { return HasPoint(p.x, p.y, eps); }
- bool HasPoint(double x, double y, double eps) const { return m_box.HasPoint(x + y, x - y, eps); }
+
+ bool HasPoint(double x, double y, double eps) const
+ {
+ return m_box.HasPoint(x + y, x - y, 2 * eps);
+ }
std::vector<m2::PointD> Points() const
{
diff --git a/indexer/cities_boundaries_serdes.hpp b/indexer/cities_boundaries_serdes.hpp
index f817527652..5c9d72a1d0 100644
--- a/indexer/cities_boundaries_serdes.hpp
+++ b/indexer/cities_boundaries_serdes.hpp
@@ -24,6 +24,7 @@
#include "base/visitor.hpp"
#include <algorithm>
+#include <cmath>
#include <cstddef>
#include <cstdint>
#include <limits>
diff --git a/search/cities_boundaries_table.cpp b/search/cities_boundaries_table.cpp
index 9c33a43946..1fceb47481 100644
--- a/search/cities_boundaries_table.cpp
+++ b/search/cities_boundaries_table.cpp
@@ -6,11 +6,13 @@
#include "search/utils.hpp"
#include "indexer/cities_boundaries_serdes.hpp"
+#include "indexer/mwm_set.hpp"
#include "coding/reader.hpp"
#include "base/assert.hpp"
#include "base/cancellable.hpp"
+#include "base/checked_cast.hpp"
#include "base/logging.hpp"
#include <algorithm>
@@ -85,7 +87,7 @@ bool CitiesBoundariesTable::Load(Index const & index)
bool CitiesBoundariesTable::Get(uint32_t fid, Boundaries & bs) const
{
- auto it = m_table.find(fid);
+ auto const it = m_table.find(fid);
if (it == m_table.end())
return false;
bs = Boundaries(it->second, m_eps);
diff --git a/search/cities_boundaries_table.hpp b/search/cities_boundaries_table.hpp
index 9a874f00c8..1c5b29c337 100644
--- a/search/cities_boundaries_table.hpp
+++ b/search/cities_boundaries_table.hpp
@@ -2,6 +2,8 @@
#include "indexer/city_boundary.hpp"
+#include "geometry/point2d.hpp"
+
#include <cstdint>
#include <unordered_map>
#include <utility>
@@ -29,6 +31,8 @@ public:
{
}
+ // Returns true iff |p| is inside any of the regions bounded by
+ // |*this|.
bool HasPoint(m2::PointD const & p) const;
private:
diff --git a/search/search_integration_tests/generate_tests.cpp b/search/search_integration_tests/generate_tests.cpp
index dd17d9f8d9..b489897a6a 100644
--- a/search/search_integration_tests/generate_tests.cpp
+++ b/search/search_integration_tests/generate_tests.cpp
@@ -5,12 +5,12 @@
#include "generator/generator_tests_support/test_mwm_builder.hpp"
#include "generator/feature_builder.hpp"
-#include "generator/osm_element.hpp"
#include "generator/osm2type.hpp"
+#include "generator/osm_element.hpp"
#include "indexer/classificator.hpp"
-#include "indexer/feature_data.hpp"
#include "indexer/feature.hpp"
+#include "indexer/feature_data.hpp"
#include "indexer/index.hpp"
#include "platform/local_country_file.hpp"
@@ -20,27 +20,33 @@ using namespace generator::tests_support;
namespace
{
-uint64_t g_lastId = 0;
-
-void MakeFeature(TestMwmBuilder & builder, pair<string, string> const & tag, m2::PointD const & pt)
+class GenerateTest : public TestWithClassificator
{
- OsmElement e;
- e.AddTag(tag.first, tag.second);
+public:
+ void MakeFeature(TestMwmBuilder & builder, pair<string, string> const & tag,
+ m2::PointD const & pt)
+ {
+ OsmElement e;
+ e.AddTag(tag.first, tag.second);
- FeatureParams params;
- ftype::GetNameAndType(&e, params);
- params.AddName("en", "xxx");
+ FeatureParams params;
+ ftype::GetNameAndType(&e, params);
+ params.AddName("en", "xxx");
- FeatureBuilder1 fb;
- fb.SetParams(params);
- fb.SetCenter(pt);
- fb.GetMetadataForTesting().Set(feature::Metadata::FMD_TEST_ID, strings::to_string(g_lastId));
- ++g_lastId;
+ FeatureBuilder1 fb;
+ fb.SetParams(params);
+ fb.SetCenter(pt);
+ fb.GetMetadataForTesting().Set(feature::Metadata::FMD_TEST_ID, strings::to_string(m_lastId));
+ ++m_lastId;
- TEST(builder.Add(fb), (fb));
-}
+ TEST(builder.Add(fb), (fb));
+ }
-UNIT_CLASS_TEST(TestWithClassificator, GenerateDeprecatedTypes)
+private:
+ uint64_t m_lastId = 0;
+};
+
+UNIT_CLASS_TEST(GenerateTest, GenerateDeprecatedTypes)
{
auto file = platform::LocalCountryFile::MakeForTesting("testCountry");
@@ -65,13 +71,9 @@ UNIT_CLASS_TEST(TestWithClassificator, GenerateDeprecatedTypes)
types.insert(cl.GetTypeByPath(s));
int count = 0;
- auto const fn = [&](FeatureType & ft)
- {
+ auto const fn = [&](FeatureType & ft) {
++count;
- ft.ForEachType([&](uint32_t t)
- {
- TEST(types.count(t) > 0, (cl.GetReadableObjectName(t)));
- });
+ ft.ForEachType([&](uint32_t t) { TEST(types.count(t) > 0, (cl.GetReadableObjectName(t))); });
};
index.ForEachInScale(fn, scales::GetUpperScale());