2015-11-10 13:49:22 +00:00
|
|
|
#include "catch.hpp"
|
|
|
|
|
2017-03-27 15:14:51 +00:00
|
|
|
#include <mapnik/geometry/is_empty.hpp>
|
2015-11-10 13:49:22 +00:00
|
|
|
|
2022-01-26 22:25:53 +00:00
|
|
|
TEST_CASE("geometry is_empty")
|
|
|
|
{
|
|
|
|
SECTION("empty geometry")
|
2015-11-10 13:49:22 +00:00
|
|
|
{
|
2022-01-26 22:25:53 +00:00
|
|
|
mapnik::geometry::geometry_empty geom;
|
2015-11-10 13:49:22 +00:00
|
|
|
REQUIRE(mapnik::geometry::is_empty(geom));
|
|
|
|
}
|
|
|
|
|
2022-01-26 22:25:53 +00:00
|
|
|
SECTION("geometry collection")
|
2015-11-10 13:49:22 +00:00
|
|
|
{
|
2022-01-26 22:25:53 +00:00
|
|
|
{
|
|
|
|
mapnik::geometry::geometry_collection<double> geom;
|
|
|
|
REQUIRE(mapnik::geometry::is_empty(geom));
|
|
|
|
}
|
|
|
|
{
|
|
|
|
mapnik::geometry::geometry_collection<double> geom;
|
|
|
|
mapnik::geometry::geometry_empty geom1;
|
|
|
|
geom.emplace_back(std::move(geom1));
|
|
|
|
REQUIRE(!mapnik::geometry::is_empty(geom));
|
|
|
|
}
|
2015-11-10 13:49:22 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:25:53 +00:00
|
|
|
SECTION("point")
|
2015-11-10 13:49:22 +00:00
|
|
|
{
|
2022-01-26 22:25:53 +00:00
|
|
|
mapnik::geometry::point<double> pt(10, 10);
|
|
|
|
REQUIRE(!mapnik::geometry::is_empty(pt));
|
2015-11-10 13:49:22 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:25:53 +00:00
|
|
|
SECTION("linestring")
|
2015-11-10 13:49:22 +00:00
|
|
|
{
|
2022-01-26 22:25:53 +00:00
|
|
|
{
|
|
|
|
mapnik::geometry::line_string<double> line;
|
|
|
|
REQUIRE(mapnik::geometry::is_empty(line));
|
|
|
|
}
|
|
|
|
{
|
|
|
|
mapnik::geometry::line_string<double> line;
|
|
|
|
line.emplace_back(0, 0);
|
|
|
|
line.emplace_back(25, 25);
|
|
|
|
line.emplace_back(50, 50);
|
|
|
|
REQUIRE(!mapnik::geometry::is_empty(line));
|
|
|
|
}
|
2015-11-10 13:49:22 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:25:53 +00:00
|
|
|
SECTION("polygon")
|
2015-11-10 13:49:22 +00:00
|
|
|
{
|
2022-01-26 22:25:53 +00:00
|
|
|
{
|
|
|
|
mapnik::geometry::polygon<double> poly;
|
|
|
|
REQUIRE(mapnik::geometry::is_empty(poly));
|
|
|
|
}
|
|
|
|
{
|
|
|
|
mapnik::geometry::polygon<double> poly;
|
|
|
|
mapnik::geometry::linear_ring<double> ring;
|
|
|
|
poly.push_back(std::move(ring));
|
|
|
|
REQUIRE(mapnik::geometry::is_empty(poly));
|
|
|
|
}
|
|
|
|
{
|
|
|
|
mapnik::geometry::polygon<double> poly;
|
|
|
|
mapnik::geometry::linear_ring<double> ring;
|
|
|
|
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);
|
|
|
|
poly.push_back(std::move(ring));
|
|
|
|
REQUIRE(!mapnik::geometry::is_empty(poly));
|
|
|
|
}
|
2015-11-10 13:49:22 +00:00
|
|
|
}
|
2022-01-26 22:25:53 +00:00
|
|
|
|
|
|
|
SECTION("multi-point")
|
2015-11-10 13:49:22 +00:00
|
|
|
{
|
2022-01-26 22:25:53 +00:00
|
|
|
{
|
|
|
|
mapnik::geometry::multi_point<double> geom;
|
|
|
|
REQUIRE(mapnik::geometry::is_empty(geom));
|
|
|
|
}
|
|
|
|
{
|
|
|
|
mapnik::geometry::multi_point<double> geom;
|
|
|
|
geom.emplace_back(0, 0);
|
|
|
|
geom.emplace_back(25, 25);
|
|
|
|
geom.emplace_back(50, 50);
|
|
|
|
REQUIRE(!mapnik::geometry::is_empty(geom));
|
|
|
|
}
|
2015-11-10 13:49:22 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:25:53 +00:00
|
|
|
SECTION("multi-linestring")
|
2015-11-10 13:49:22 +00:00
|
|
|
{
|
2022-01-26 22:25:53 +00:00
|
|
|
{
|
|
|
|
mapnik::geometry::multi_line_string<double> geom;
|
|
|
|
REQUIRE(mapnik::geometry::is_empty(geom));
|
|
|
|
}
|
|
|
|
{
|
|
|
|
mapnik::geometry::multi_line_string<double> geom;
|
|
|
|
mapnik::geometry::line_string<double> line;
|
|
|
|
geom.emplace_back(std::move(line));
|
|
|
|
REQUIRE(!mapnik::geometry::is_empty(geom));
|
|
|
|
}
|
2015-11-10 13:49:22 +00:00
|
|
|
}
|
2022-01-26 22:25:53 +00:00
|
|
|
|
|
|
|
SECTION("multi-polygon")
|
2015-11-10 13:49:22 +00:00
|
|
|
{
|
2022-01-26 22:25:53 +00:00
|
|
|
{
|
|
|
|
mapnik::geometry::multi_polygon<double> geom;
|
|
|
|
REQUIRE(mapnik::geometry::is_empty(geom));
|
|
|
|
}
|
|
|
|
{
|
|
|
|
mapnik::geometry::multi_polygon<double> geom;
|
|
|
|
mapnik::geometry::polygon<double> poly;
|
|
|
|
mapnik::geometry::linear_ring<double> ring;
|
|
|
|
poly.push_back(std::move(ring));
|
|
|
|
geom.emplace_back(std::move(poly));
|
|
|
|
REQUIRE(!mapnik::geometry::is_empty(geom));
|
|
|
|
}
|
2015-11-10 13:49:22 +00:00
|
|
|
}
|
|
|
|
}
|