diff --git a/geometry/cellid.hpp b/geometry/cellid.hpp index 20acd6621e..509747eacb 100644 --- a/geometry/cellid.hpp +++ b/geometry/cellid.hpp @@ -169,7 +169,7 @@ public: return xy; } - static CellId FromXY(uint32_t x, uint32_t y, int level = DEPTH_LEVELS - 1) + static CellId FromXY(uint32_t x, uint32_t y, int level) { ASSERT_LESS(level, static_cast(DEPTH_LEVELS), (x, y, level)); // Since MAX_COORD == 1 << DEPTH_LEVELS, if x|y == MAX_COORD, they should be decremented. diff --git a/geometry/geometry_tests/cellid_test.cpp b/geometry/geometry_tests/cellid_test.cpp index 3bc265e9f7..389b686c88 100644 --- a/geometry/geometry_tests/cellid_test.cpp +++ b/geometry/geometry_tests/cellid_test.cpp @@ -95,12 +95,11 @@ UNIT_TEST(CellId_Radius) UNIT_TEST(CellId_FromXY) { - TEST_EQUAL((m2::CellId<3>::FromXY(0, 0)), (m2::CellId<3>("00")), ()); TEST_EQUAL((m2::CellId<3>::FromXY(0, 0, 2)), (m2::CellId<3>("00")), ()); TEST_EQUAL((m2::CellId<3>::FromXY(0, 0, 1)), (m2::CellId<3>("0")), ()); TEST_EQUAL((m2::CellId<3>::FromXY(0, 0, 0)), (m2::CellId<3>("")), ()); TEST_EQUAL((m2::CellId<3>::FromXY(5, 4, 0)), (m2::CellId<3>("")), ()); - TEST_EQUAL((m2::CellId<3>::FromXY(5, 0)), (m2::CellId<3>("10")), ()); + TEST_EQUAL((m2::CellId<3>::FromXY(5, 0, 2)), (m2::CellId<3>("10")), ()); TEST_EQUAL((m2::CellId<3>::FromXY(5, 0, 1)), (m2::CellId<3>("1")), ()); TEST_EQUAL((m2::CellId<3>::FromXY(5, 0, 1)), (m2::CellId<3>("1")), ()); TEST_EQUAL((m2::CellId<3>::FromXY(7, 7, 2)), (m2::CellId<3>("33")), ()); @@ -111,10 +110,10 @@ UNIT_TEST(CellId_FromXY) UNIT_TEST(CellId_FromXY_XY_Match) { - TEST_EQUAL((m2::CellId<9>::FromXY(48, 80).XY()), make_pair(49U, 81U), ()); - TEST_EQUAL((m2::CellId<9>::FromXY(192, 320).XY()), make_pair(193U, 321U), ()); - TEST_EQUAL((m2::CellId<11>::FromXY(768, 1280).XY()), make_pair(769U, 1281U), ()); - TEST_EQUAL((m2::CellId<21>::FromXY(786432, 1310720).XY()), make_pair(786433U, 1310721U), ()); + TEST_EQUAL((m2::CellId<9>::FromXY(48, 80, 8).XY()), make_pair(49U, 81U), ()); + TEST_EQUAL((m2::CellId<9>::FromXY(192, 320, 8).XY()), make_pair(193U, 321U), ()); + TEST_EQUAL((m2::CellId<11>::FromXY(768, 1280, 10).XY()), make_pair(769U, 1281U), ()); + TEST_EQUAL((m2::CellId<21>::FromXY(786432, 1310720, 20).XY()), make_pair(786433U, 1310721U), ()); } UNIT_TEST(CellId_SubTreeSize) diff --git a/geometry/geometry_tests/covering_test.cpp b/geometry/geometry_tests/covering_test.cpp index 98fce5a855..a9b7b13d40 100644 --- a/geometry/geometry_tests/covering_test.cpp +++ b/geometry/geometry_tests/covering_test.cpp @@ -104,7 +104,7 @@ UNIT_TEST(IntersectCellWithTriangle_EmptyTriangle) UNIT_TEST(Covering_EmptyTriangle) { m2::PointU pt(27, 31); - CellId const expectedCellId = CellId::FromXY(pt.x, pt.y); + CellId const expectedCellId = CellId::FromXY(pt.x, pt.y, CellId::DEPTH_LEVELS - 1); TEST_GREATER(expectedCellId.ToInt64(), 5, ()); covering::Covering covering(pt, pt, pt); vector ids; diff --git a/indexer/cell_id.hpp b/indexer/cell_id.hpp index d0ee6641b6..1a4e62f143 100644 --- a/indexer/cell_id.hpp +++ b/indexer/cell_id.hpp @@ -45,7 +45,7 @@ public: { uint32_t const ix = static_cast(XToCellIdX(x)); uint32_t const iy = static_cast(YToCellIdY(y)); - CellIdT id = CellIdT::FromXY(ix, iy); + CellIdT id = CellIdT::FromXY(ix, iy, CellIdT::DEPTH_LEVELS - 1); #if 0 // DEBUG pair ixy = id.XY(); ASSERT(Abs(ixy.first - ix) <= 1, (x, y, id, ixy)); diff --git a/indexer/feature_covering.cpp b/indexer/feature_covering.cpp index 452feea7cc..3ecd715d67 100644 --- a/indexer/feature_covering.cpp +++ b/indexer/feature_covering.cpp @@ -105,7 +105,8 @@ vector CoverFeature(FeatureType const & f, uint64_t cellPenaltyArea) { m2::PointD pt = featureIntersector.m_Polyline[0]; return vector( - 1, RectId::FromXY(static_cast(pt.x), static_cast(pt.y)).ToInt64()); + 1, RectId::FromXY(static_cast(pt.x), static_cast(pt.y), + RectId::DEPTH_LEVELS - 1).ToInt64()); } vector cells;