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