2015-11-24 16:41:34 +01:00
|
|
|
#include "catch.hpp"
|
|
|
|
|
2017-03-27 17:14:51 +02:00
|
|
|
#include <mapnik/geometry/remove_empty.hpp>
|
2015-11-24 16:41:34 +01:00
|
|
|
|
|
|
|
TEST_CASE("geometry remove_empty") {
|
|
|
|
|
|
|
|
SECTION("point") {
|
|
|
|
|
|
|
|
using geom_type = mapnik::geometry::point<double>;
|
|
|
|
geom_type pt(10, 10);
|
|
|
|
geom_type pt2 = mapnik::geometry::remove_empty(pt);
|
|
|
|
REQUIRE(pt.x == pt2.x);
|
|
|
|
REQUIRE(pt.y == pt2.y);
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("multi-linestring") {
|
|
|
|
|
|
|
|
using geom_type = mapnik::geometry::multi_line_string<double>;
|
|
|
|
geom_type geom;
|
|
|
|
mapnik::geometry::line_string<double> line;
|
2016-06-27 11:23:13 +02:00
|
|
|
line.emplace_back(0, 0);
|
|
|
|
line.emplace_back(0, 25);
|
|
|
|
line.emplace_back(0, 50);
|
2015-11-24 16:41:34 +01:00
|
|
|
geom.emplace_back(std::move(line));
|
|
|
|
geom.emplace_back();
|
|
|
|
|
|
|
|
REQUIRE(geom.size() == 2);
|
|
|
|
geom_type geom2 = mapnik::geometry::remove_empty(geom);
|
|
|
|
REQUIRE(geom2.size() == 1);
|
|
|
|
REQUIRE(geom2[0].size() == 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("multi-polygon") {
|
|
|
|
|
|
|
|
using geom_type = mapnik::geometry::multi_polygon<double>;
|
|
|
|
geom_type geom;
|
|
|
|
mapnik::geometry::polygon<double> poly;
|
|
|
|
mapnik::geometry::linear_ring<double> ring;
|
2016-06-27 11:23:13 +02:00
|
|
|
ring.emplace_back(0, 0);
|
|
|
|
ring.emplace_back(1, 0);
|
|
|
|
ring.emplace_back(1, 1);
|
|
|
|
ring.emplace_back(0, 1);
|
|
|
|
ring.emplace_back(0, 0);
|
2016-06-29 13:37:32 +02:00
|
|
|
poly.push_back(std::move(ring));
|
2015-11-24 16:41:34 +01:00
|
|
|
geom.emplace_back(std::move(poly));
|
|
|
|
geom.emplace_back();
|
2016-06-29 13:37:32 +02:00
|
|
|
//geom.back().emplace_back(); //add an empty exterior ring
|
2015-11-24 16:41:34 +01:00
|
|
|
REQUIRE(geom.size() == 2);
|
|
|
|
geom_type geom2 = mapnik::geometry::remove_empty(geom);
|
|
|
|
REQUIRE(geom2.size() == 1);
|
2016-06-29 13:37:32 +02:00
|
|
|
REQUIRE(geom2.front().front().size() == 5);
|
2015-11-24 16:41:34 +01:00
|
|
|
}
|
|
|
|
}
|