2018-01-17 14:36:28 +01:00
|
|
|
#include "catch.hpp"
|
|
|
|
|
|
|
|
#include <mapnik/geometry/polylabel.hpp>
|
|
|
|
|
2022-01-26 23:25:53 +01:00
|
|
|
TEST_CASE("polylabel")
|
|
|
|
{
|
|
|
|
SECTION("empty polygon")
|
|
|
|
{
|
|
|
|
mapnik::geometry::polygon<double> poly;
|
|
|
|
mapnik::geometry::point<double> pt;
|
|
|
|
|
|
|
|
CHECK(!mapnik::geometry::polylabel(poly, 1.0, pt));
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("empty exterior ring")
|
|
|
|
{
|
|
|
|
mapnik::geometry::polygon<double> poly;
|
|
|
|
poly.emplace_back();
|
|
|
|
|
|
|
|
mapnik::geometry::point<double> pt;
|
|
|
|
|
|
|
|
CHECK(!mapnik::geometry::polylabel(poly, 1.0, pt));
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("polylabel with a square")
|
|
|
|
{
|
|
|
|
mapnik::geometry::polygon<double> poly;
|
|
|
|
poly.emplace_back();
|
|
|
|
auto& exterior_ring = poly.front();
|
|
|
|
exterior_ring.emplace_back(-1, -1);
|
|
|
|
exterior_ring.emplace_back(1, -1);
|
|
|
|
exterior_ring.emplace_back(1, 1);
|
|
|
|
exterior_ring.emplace_back(-1, 1);
|
|
|
|
exterior_ring.emplace_back(-1, -1);
|
|
|
|
|
|
|
|
mapnik::geometry::point<double> pt{-3, -3};
|
|
|
|
|
|
|
|
CHECK(mapnik::geometry::polylabel(poly, 1.0, pt));
|
|
|
|
CHECK(pt.x == Approx(0));
|
|
|
|
CHECK(pt.y == Approx(0));
|
|
|
|
}
|
2018-01-17 14:36:28 +01:00
|
|
|
}
|