Skip to content

Commit

Permalink
Merge pull request #901 from PDAL/issue-897
Browse files Browse the repository at this point in the history
Added note & test for "2D" BBOX3 question
  • Loading branch information
hobu committed May 8, 2015
2 parents 75c9bf4 + 4aa5b27 commit 1e88648
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
5 changes: 4 additions & 1 deletion include/pdal/util/Bounds.hpp
Expand Up @@ -79,6 +79,10 @@ class PDAL_DLL BOX3D
minz(box.minz), maxz(box.maxz)
{}

// Note: a "2D" bbox is explicitly constructed to have invalid Z values,
// which might lead to some problems when used in conjuction with a "3D"
// bbox. See, for example, issue #897.
// Note: ctor body not inlined due to MSVC, see #900
BOX3D(double minx, double miny, double maxx, double maxy) ;

BOX3D(double minx, double miny, double minz, double maxx, double maxy,
Expand Down Expand Up @@ -251,4 +255,3 @@ inline std::ostream& operator << (std::ostream& ostr, const BOX3D& bounds)
extern PDAL_DLL std::istream& operator>>(std::istream& istr, BOX3D& bounds);

} // namespace pdal

17 changes: 17 additions & 0 deletions test/unit/BoundsTest.cpp
Expand Up @@ -234,3 +234,20 @@ TEST(BoundsTest, test_2d_input)
BOX3D r(1.1,2.2,101.1,102.2);
EXPECT_EQ(r, rr);
}

TEST(BoundsTest, test_issue_897)
{
BOX3D boxA(0.0, 0.0, 100.0, 100.0); // a "2D" box
BOX3D boxB(50.0, 50.0, 3.1, 51.0, 51.0, 3.14); // a "3D" box, wholly inside boxA

// Currently aContainsB is false: see issue #387.
const bool aContainsB = boxA.contains(boxB);
const bool bContainsA = boxB.contains(boxA);
const bool aContainsA = boxA.contains(boxA);
const bool bContainsB = boxB.contains(boxB);

EXPECT_FALSE(aContainsB);
EXPECT_FALSE(bContainsA);
EXPECT_TRUE(aContainsA);
EXPECT_TRUE(bContainsB);
}

0 comments on commit 1e88648

Please sign in to comment.