diff --git a/filters/private/hexer/Path.cpp b/filters/private/hexer/Path.cpp index a16845ef62..7cf62a88b0 100644 --- a/filters/private/hexer/Path.cpp +++ b/filters/private/hexer/Path.cpp @@ -32,6 +32,8 @@ * OF SUCH DAMAGE. ****************************************************************************/ +#include + #include "Path.hpp" using namespace std; diff --git a/test/unit/filters/HexbinFilterTest.cpp b/test/unit/filters/HexbinFilterTest.cpp index ef4b221162..8d97c7351d 100644 --- a/test/unit/filters/HexbinFilterTest.cpp +++ b/test/unit/filters/HexbinFilterTest.cpp @@ -35,6 +35,7 @@ #include #include +#include #include #include @@ -94,3 +95,37 @@ TEST(HexbinFilterTest, HexbinFilterTest_test_1) out.close(); FileUtils::deleteFile(filename); } + +// Test that we create proper WKT for geometry with islands. +TEST(HexbinFilterTest, issue_2507) +{ + hexer::HexGrid grid(1); + + // This is an arrangement with two holes. One of the holes has two + // islands and one of those islands has a hole. + std::vector> hexes { + {0, 3}, {0, 4}, {0,5}, {0, 6}, + {1, 2}, {1, 6}, + {2, 2}, {2, 4}, {2, 5}, {2, 7}, + {3, 1}, {3, 3}, {3, 5}, {3, 7}, + {4, 1}, {4, 2}, {4, 4}, {4, 5}, {4, 8}, + {5, 0}, {5, 2}, {5, 6}, {5, 8}, + {6, 1}, {6, 3}, {6, 4}, {6, 8}, + {7, 1}, {7, 3}, {7, 4}, {7, 5}, {7, 7}, + {8, 2}, {8, 3}, {8, 4}, {8, 5}, {8, 6}, {8, 7} + }; + + for (auto p : hexes) + grid.addDenseHexagon(p.first, p.second); + grid.findShapes(); + grid.findParentPaths(); + + std::ostringstream oss; + grid.toWKT(oss); + std::string s(oss.str()); + + std::string test = + R"delim(MULTIPOLYGON (((-5 -0.5, -5 -0.5, -6 -1, -6 -1, -7 -1.5, -7 -1.5, -8 -2, -8 -2, -8 -2, -8 -3, -8 -3, -8 -4, -8 -4, -8 -5, -8 -5, -8 -6, -8 -6, -8 -7, -8 -7, -8 -7, -7 -7.5, -7 -7.5, -6 -8, -6 -8, -5 -8.5, -5 -8.5, -5 -8.5, -4 -8, -4 -8, -3 -7.5, -3 -7.5, -2 -7, -2 -7, -1 -6.5, -1 -6.5, 0 -6, 0 -6, 0 -6, 0 -5, 0 -5, 0 -4, 0 -4, 0 -3, 0 -3, 0 -3, -1 -2.5, -1 -2.5, -2 -2, -2 -2, -3 -1.5, -3 -1.5, -4 -1, -4 -1, -5 -0.5, -5 -0.5), (-4 -2, -4 -1, -5 -0.5, -6 -1, -6 -1, -7 -1.5, -7 -1.5, -8 -2, -8 -3, -7 -3.5, -6 -3, -6 -3, -5 -2.5, -5 -2.5, -4 -2), (0 -6, 0 -5, 0 -5, 0 -4, 0 -4, 0 -3, -1 -2.5, -1 -2.5, -2 -2, -2 -2, -3 -1.5, -4 -2, -4 -2, -5 -2.5, -5 -2.5, -6 -3, -6 -4, -6 -4, -6 -4, -7 -4.5, -7 -5.5, -7 -5.5, -7 -5.5, -8 -6, -8 -7, -7 -7.5, -7 -7.5, -6 -8, -6 -8, -5 -8.5, -4 -8, -4 -8, -3 -7.5, -3 -7.5, -2 -7, -2 -7, -1 -6.5, -1 -6.5, 0 -6)), ((-3 -3.5, -3 -3.5, -4 -4, -4 -4, -4 -4, -4 -5, -4 -5, -4 -5, -3 -5.5, -3 -5.5, -3 -5.5, -2 -5, -2 -5, -2 -5, -2 -4, -2 -4, -2 -4, -3 -3.5, -3 -3.5), (-2 -5, -2 -4, -3 -3.5, -4 -4, -4 -5, -3 -5.5, -2 -5)), ((-5 -6.5, -5 -6.5, -5 -6.5, -5 -6.5, -5 -6.5, -5 -6.5, -5 -6.5))))delim"; + EXPECT_EQ(s, test); +} +