Skip to content

Commit

Permalink
fix boundary condition
Browse files Browse the repository at this point in the history
  • Loading branch information
mpgerlek committed May 27, 2015
1 parent 0a81eef commit 25b6a5e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
2 changes: 1 addition & 1 deletion filters/tiler/TilerCommon.hpp
Expand Up @@ -138,7 +138,7 @@ class TileMatrixMath
const double w = tileWidthAtLevel(level);
const double h = tileHeightAtLevel(level);
col = std::floor((x - m_minx) / w);
row = std::floor((m_maxy - y) / h) - 1;
row = std::ceil((m_maxy - y) / h) - 1.0;
}

bool tileContains(uint32_t col, uint32_t row, uint32_t level,
Expand Down
41 changes: 41 additions & 0 deletions test/unit/filters/TilerTest.cpp
Expand Up @@ -892,3 +892,44 @@ TEST(TilerTest, test_cartesian_10x20)
++iter;
EXPECT_EQ(outputViews.end(), iter);
}

TEST(TilerTest, test_boundary_bug)
{
const double minx = -179.9;
const double miny = -89.9;
const double maxx = 179.9;
const double maxy = 89.9;

const tilercommon::TileMatrixMath tmm(-180.0, -90.0, 180.0, 90.0, 2, 1);
uint32_t mincol, minrow, maxcol, maxrow;

{
tmm.getTileOfPoint(minx, miny, 0, mincol, minrow);
tmm.getTileOfPoint(maxx, maxy, 0, maxcol, maxrow);

EXPECT_EQ(0u, mincol);
EXPECT_EQ(0u, minrow);
EXPECT_EQ(1u, maxcol);
EXPECT_EQ(0u, maxrow);
}

{
tmm.getTileOfPoint(minx, miny, 1, mincol, minrow);
tmm.getTileOfPoint(maxx, maxy, 1, maxcol, maxrow);

EXPECT_EQ(0u, mincol);
EXPECT_EQ(1u, minrow);
EXPECT_EQ(3u, maxcol);
EXPECT_EQ(0u, maxrow);
}

{
tmm.getTileOfPoint(minx, miny, 2, mincol, minrow);
tmm.getTileOfPoint(maxx, maxy, 2, maxcol, maxrow);

EXPECT_EQ(0u, mincol);
EXPECT_EQ(3u, minrow);
EXPECT_EQ(7u, maxcol);
EXPECT_EQ(0u, maxrow);
}
}

0 comments on commit 25b6a5e

Please sign in to comment.